Commit 6af8aaac5fcb5190f2f5952095a0660a5ec17099

Authored by anderson.peterle@previdencia.gov.br
1 parent d3353de5
Exists in master

Adequacoes ao uso de library unica, para reaproveitamento de codigos, propriedad…

…es e metodos, faxina de codigo.

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@764 fecfc0c7-e812-0410-ae72-849f08638ee7
col_soft/col_soft.dpr
... ... @@ -30,45 +30,25 @@ uses
30 30 MSI_ENGINES,
31 31 MSI_OS,
32 32 MSI_XML_Reports,
33   - DCPcrypt2,
34   - DCPrijndael,
35   - DCPbase64,
36 33 CACIC_Library in '..\CACIC_Library.pas';
37 34  
38   -var p_path_cacic,
39   - v_CipherKey,
40   - v_IV,
41   - v_strCipherClosed,
42   - v_DatFileName : String;
43   - v_Debugs : boolean;
44   -var v_tstrCipherOpened,
45   - v_tstrCipherOpened1 : TStrings;
46   -
47   -// Some constants that are dependant on the cipher being used
48   -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
49   -const KeySize = 32; // 32 bytes = 256 bits
50   - BlockSize = 16; // 16 bytes = 128 bits
51   -
52   -function HomeDrive : string;
53 35 var
54   -WinDir : array [0..144] of char;
55   -begin
56   -GetWindowsDirectory (WinDir, 144);
57   -Result := StrPas (WinDir);
58   -end;
  36 + v_strCipherClosed : String;
  37 + v_Debugs : boolean;
59 38  
60   -Function Implode(p_Array : TStrings ; p_Separador : String) : String;
61   -var intAux : integer;
62   - strAux : string;
63   -Begin
64   - strAux := '';
65   - For intAux := 0 To p_Array.Count -1 do
66   - Begin
67   - if (strAux<>'') then strAux := strAux + p_Separador;
68   - strAux := strAux + p_Array[intAux];
69   - End;
70   - Implode := strAux;
71   -end;
  39 +var
  40 + v_tstrCipherOpened,
  41 + v_tstrCipherOpened1,
  42 + tstrTripa1 : TStrings;
  43 +
  44 +var
  45 + intAux : integer;
  46 +
  47 +var
  48 + g_oCacic : TCACIC;
  49 +
  50 +const
  51 + CACIC_APP_NAME = 'col_soft';
72 52  
73 53 procedure log_diario(strMsg : String);
74 54 var
... ... @@ -76,8 +56,8 @@ var
76 56 strDataArqLocal, strDataAtual : string;
77 57 begin
78 58 try
79   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
80   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
  59 + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  60 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
81 61 {$IOChecks off}
82 62 Reset(HistoricoLog); {Abre o arquivo texto}
83 63 {$IOChecks on}
... ... @@ -87,7 +67,7 @@ begin
87 67 Append(HistoricoLog);
88 68 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
89 69 end;
90   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
  70 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log')));
91 71 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
92 72 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
93 73 begin
... ... @@ -105,94 +85,6 @@ begin
105 85 end;
106 86 end;
107 87  
108   -// Pad a string with zeros so that it is a multiple of size
109   -function PadWithZeros(const str : string; size : integer) : string;
110   -var
111   - origsize, i : integer;
112   -begin
113   - Result := str;
114   - origsize := Length(Result);
115   - if ((origsize mod size) <> 0) or (origsize = 0) then
116   - begin
117   - SetLength(Result,((origsize div size)+1)*size);
118   - for i := origsize+1 to Length(Result) do
119   - Result[i] := #0;
120   - end;
121   -end;
122   -
123   -
124   -// Encrypt a string and return the Base64 encoded result
125   -function EnCrypt(p_Data : String) : String;
126   -var
127   - l_Cipher : TDCP_rijndael;
128   - l_Data, l_Key, l_IV : string;
129   -begin
130   - Try
131   - // Pad Key, IV and Data with zeros as appropriate
132   - l_Key := PadWithZeros(v_CipherKey,KeySize);
133   - l_IV := PadWithZeros(v_IV,BlockSize);
134   - l_Data := PadWithZeros(p_Data,BlockSize);
135   -
136   - // Create the cipher and initialise according to the key length
137   - l_Cipher := TDCP_rijndael.Create(nil);
138   - if Length(v_CipherKey) <= 16 then
139   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
140   - else if Length(v_CipherKey) <= 24 then
141   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
142   - else
143   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
144   -
145   - // Encrypt the data
146   - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));
147   -
148   - // Free the cipher and clear sensitive information
149   - l_Cipher.Free;
150   - FillChar(l_Key[1],Length(l_Key),0);
151   -
152   - // Return the Base64 encoded result
153   - Result := Base64EncodeStr(l_Data);
154   - Except
155   - log_diario('Erro no Processo de Criptografia');
156   - End;
157   -end;
158   -
159   -function DeCrypt(p_Data : String) : String;
160   -var
161   - l_Cipher : TDCP_rijndael;
162   - l_Data, l_Key, l_IV : string;
163   -begin
164   - Try
165   - // Pad Key and IV with zeros as appropriate
166   - l_Key := PadWithZeros(v_CipherKey,KeySize);
167   - l_IV := PadWithZeros(v_IV,BlockSize);
168   -
169   - // Decode the Base64 encoded string
170   - l_Data := Base64DecodeStr(p_Data);
171   -
172   - // Create the cipher and initialise according to the key length
173   - l_Cipher := TDCP_rijndael.Create(nil);
174   - if Length(v_CipherKey) <= 16 then
175   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
176   - else if Length(v_CipherKey) <= 24 then
177   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
178   - else
179   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
180   -
181   - // Decrypt the data
182   - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));
183   -
184   - // Free the cipher and clear sensitive information
185   - l_Cipher.Free;
186   - FillChar(l_Key[1],Length(l_Key),0);
187   -
188   - // Return the result
189   - Result := l_Data;
190   - Except
191   - log_diario('Erro no Processo de Decriptografia');
192   - End;
193   -end;
194   -
195   -
196 88 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
197 89 var v_strCipherOpenImploded : string;
198 90 v_DatFile : TextFile;
... ... @@ -205,13 +97,8 @@ begin
205 97 Rewrite (v_DatFile);
206 98 Append(v_DatFile);
207 99  
208   - //v_Cipher := TDCP_rijndael.Create(nil);
209   - //v_Cipher.InitStr(v_CipherKey,TDCP_md5);
210   - v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
211   - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
212   - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded);
213   - //v_Cipher.Burn;
214   - //v_Cipher.Free;
  100 + v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey);
  101 + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded);
215 102  
216 103 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
217 104  
... ... @@ -220,37 +107,6 @@ begin
220 107 end;
221 108 end;
222 109  
223   -Function Explode(Texto, Separador : String) : TStrings;
224   -var
225   - strItem : String;
226   - ListaAuxUTILS : TStrings;
227   - NumCaracteres,
228   - TamanhoSeparador,
229   - I : Integer;
230   -Begin
231   - ListaAuxUTILS := TStringList.Create;
232   - strItem := '';
233   - NumCaracteres := Length(Texto);
234   - TamanhoSeparador := Length(Separador);
235   - I := 1;
236   - While I <= NumCaracteres Do
237   - Begin
238   - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then
239   - Begin
240   - if (I = NumCaracteres) then strItem := strItem + Texto[I];
241   - ListaAuxUTILS.Add(trim(strItem));
242   - strItem := '';
243   - I := I + (TamanhoSeparador-1);
244   - end
245   - Else
246   - strItem := strItem + Texto[I];
247   -
248   - I := I + 1;
249   - End;
250   - Explode := ListaAuxUTILS;
251   -end;
252   -
253   -
254 110 Function CipherOpen(p_DatFileName : string) : TStrings;
255 111 var v_DatFile : TextFile;
256 112 v_strCipherOpened,
... ... @@ -272,12 +128,12 @@ begin
272 128 Readln(v_DatFile,v_strCipherClosed);
273 129 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed);
274 130 CloseFile(v_DatFile);
275   - v_strCipherOpened:= DeCrypt(v_strCipherClosed);
  131 + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
276 132 end;
277 133 if (trim(v_strCipherOpened)<>'') then
278   - Result := explode(v_strCipherOpened,'=CacicIsFree=')
  134 + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey)
279 135 else
280   - Result := explode('Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  136 + Result := g_oCacic.explode('Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey);
281 137  
282 138 if Result.Count mod 2 <> 0 then
283 139 Result.Add('');
... ... @@ -294,6 +150,7 @@ begin
294 150 p_tstrCipherOpened.Add(p_Valor);
295 151 End;
296 152 end;
  153 +
297 154 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
298 155 begin
299 156 if (p_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
... ... @@ -444,7 +301,7 @@ var
444 301 strDataArqLocal, strDataAtual, v_file_debugs : string;
445 302 begin
446 303 try
447   - v_file_debugs := p_path_cacic + '\Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
  304 + v_file_debugs := g_oCacic.getCacicPath + 'Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
448 305 FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
449 306 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile}
450 307  
... ... @@ -509,7 +366,7 @@ var RegEditGet: TRegistry;
509 366 begin
510 367 try
511 368 Result := '';
512   - ListaAuxGet := Explode(Chave, ');
  369 + ListaAuxGet := g_oCacic.explode(Chave, ');
513 370  
514 371 strRootKey := ListaAuxGet[0];
515 372 For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
... ... @@ -742,12 +599,12 @@ begin
742 599 SetValorDatMemoria('Col_Soft.te_inventario_softwares' , te_inventario_softwares , v_tstrCipherOpened1);
743 600 SetValorDatMemoria('Col_Soft.te_variaveis_ambiente' , te_variaveis_ambiente , v_tstrCipherOpened1);
744 601 SetValorDatMemoria('Col_Soft.UVC' , UVC , v_tstrCipherOpened1);
745   - CipherClose(p_path_cacic + 'temp\col_soft.dat', v_tstrCipherOpened1);
  602 + CipherClose(g_oCacic.getCacicPath + 'temp\col_soft.dat', v_tstrCipherOpened1);
746 603 end
747 604 else
748 605 Begin
749 606 SetValorDatMemoria('Col_Soft.nada', 'nada', v_tstrCipherOpened1);
750   - CipherClose(p_path_cacic + 'temp\col_soft.dat', v_tstrCipherOpened1);
  607 + CipherClose(g_oCacic.getCacicPath + 'temp\col_soft.dat', v_tstrCipherOpened1);
751 608 End;
752 609 v_ENGINES.Free;
753 610  
... ... @@ -765,71 +622,49 @@ begin
765 622 Begin
766 623 SetValorDatMemoria('Col_Soft.nada', 'nada', v_tstrCipherOpened1);
767 624 SetValorDatMemoria('Col_Soft.Fim' , '99999999', v_tstrCipherOpened1);
768   - CipherClose(p_path_cacic + 'temp\col_soft.dat', v_tstrCipherOpened1);
  625 + CipherClose(g_oCacic.getCacicPath + 'temp\col_soft.dat', v_tstrCipherOpened1);
769 626 End;
770 627 End;
771 628 end;
772 629  
773   -const
774   - CACIC_APP_NAME = 'col_soft';
775   -
776   -var
777   - tstrTripa1 : TStrings;
778   - intAux : integer;
779   - oCacic : TCACIC;
780   -
  630 +var v_path_cacic : String;
781 631 begin
782   - oCacic := TCACIC.Create();
  632 + g_oCacic := TCACIC.Create();
783 633  
784   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  634 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
785 635 if (ParamCount>0) then
786   - Begin
787   - For intAux := 1 to ParamCount do
788   - Begin
789   - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then
790   - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux)))));
791   - End;
792   -
793   - if (trim(v_CipherKey)<>'') then
794   - Begin
795   -
796   - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
797   - tstrTripa1 := explode(ExtractFilePath(ParamStr(0)),'\');
798   - p_path_cacic := '';
799   - For intAux := 0 to tstrTripa1.Count -2 do
800   - begin
801   - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\';
802   - end;
803   -
804   - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave.
805   - v_IV := 'abcdefghijklmnop';
806   - v_DatFileName := p_path_cacic + '\cacic2.dat';
807   - v_tstrCipherOpened := TStrings.Create;
808   - v_tstrCipherOpened := CipherOpen(v_DatFileName);
809   -
810   - v_tstrCipherOpened1 := TStrings.Create;
811   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'temp\col_soft.dat');
812   -
813   - Try
814   - v_Debugs := false;
815   -
816   - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then
817   - Begin
818   - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
819   - Begin
820   - v_Debugs := true;
821   - log_diario('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
822   - End;
823   - End;
824   -
825   - Executa_Col_Soft;
826   - Except
827   - SetValorDatMemoria('Col_Soft.nada', 'nada', v_tstrCipherOpened1);
828   - CipherClose(p_path_cacic + 'temp\col_soft.dat', v_tstrCipherOpened1);
829   - End;
830   - End;
  636 + Begin
  637 + //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
  638 + tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\');
  639 + v_path_cacic := '';
  640 + For intAux := 0 to tstrTripa1.Count -2 do
  641 + v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\';
  642 +
  643 + v_tstrCipherOpened := TStrings.Create;
  644 + v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName);
  645 +
  646 + v_tstrCipherOpened1 := TStrings.Create;
  647 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_soft.dat');
  648 +
  649 + Try
  650 + v_Debugs := false;
  651 +
  652 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
  653 + Begin
  654 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
  655 + Begin
  656 + v_Debugs := true;
  657 + log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
  658 + End;
  659 + End;
  660 +
  661 + Executa_Col_Soft;
  662 + Except
  663 + SetValorDatMemoria('Col_Soft.nada', 'nada', v_tstrCipherOpened1);
  664 + CipherClose(g_oCacic.getCacicPath + 'temp\col_soft.dat', v_tstrCipherOpened1);
  665 + End;
831 666 End;
832 667  
833   - oCacic.Free();
  668 + g_oCacic.Free();
834 669  
835 670 end.
... ...
col_undi/col_undi.dpr
... ... @@ -29,56 +29,34 @@ uses
29 29 Registry,
30 30 MSI_DISK,
31 31 MSI_XML_Reports,
32   - DCPcrypt2,
33   - DCPrijndael,
34   - DCPbase64,
35 32 CACIC_Library in '..\CACIC_Library.pas';
36 33  
37   -var p_path_cacic,
38   - v_CipherKey,
39   - v_IV,
40   - v_strCipherClosed,
41   - v_DatFileName : String;
42   - v_debugs : boolean;
43   -
44   -var v_tstrCipherOpened,
45   - v_tstrCipherOpened1 : TStrings;
  34 +var
  35 + v_strCipherClosed : String;
  36 + v_debugs : boolean;
46 37  
47   -var g_oCacic : TCACIC;
  38 +var
  39 + v_tstrCipherOpened,
  40 + v_tstrCipherOpened1,
  41 + tstrTripa1 : TStrings;
48 42  
49   -// Some constants that are dependant on the cipher being used
50   -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
51   -const KeySize = 32; // 32 bytes = 256 bits
52   - BlockSize = 16; // 16 bytes = 128 bits
  43 +var
  44 + intAux : integer;
53 45  
54   -function HomeDrive : string;
55 46 var
56   -WinDir : array [0..144] of char;
57   -begin
58   -GetWindowsDirectory (WinDir, 144);
59   -Result := StrPas (WinDir);
60   -end;
  47 + g_oCacic : TCACIC;
  48 +
  49 +const
  50 + CACIC_APP_NAME = 'col_undi';
61 51  
62   -Function Implode(p_Array : TStrings ; p_Separador : String) : String;
63   -var intAux : integer;
64   - strAux : string;
65   -Begin
66   - strAux := '';
67   - For intAux := 0 To p_Array.Count -1 do
68   - Begin
69   - if (strAux<>'') then strAux := strAux + p_Separador;
70   - strAux := strAux + p_Array[intAux];
71   - End;
72   - Implode := strAux;
73   -end;
74 52 procedure log_diario(strMsg : String);
75 53 var
76 54 HistoricoLog : TextFile;
77 55 strDataArqLocal, strDataAtual : string;
78 56 begin
79 57 try
80   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
81   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
  58 + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  59 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
82 60 {$IOChecks off}
83 61 Reset(HistoricoLog); {Abre o arquivo texto}
84 62 {$IOChecks on}
... ... @@ -88,7 +66,7 @@ begin
88 66 Append(HistoricoLog);
89 67 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
90 68 end;
91   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
  69 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log')));
92 70 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
93 71 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
94 72 begin
... ... @@ -103,92 +81,6 @@ begin
103 81 log_diario('Erro na gravação do log!');
104 82 end;
105 83 end;
106   -// Pad a string with zeros so that it is a multiple of size
107   -function PadWithZeros(const str : string; size : integer) : string;
108   -var
109   - origsize, i : integer;
110   -begin
111   - Result := str;
112   - origsize := Length(Result);
113   - if ((origsize mod size) <> 0) or (origsize = 0) then
114   - begin
115   - SetLength(Result,((origsize div size)+1)*size);
116   - for i := origsize+1 to Length(Result) do
117   - Result[i] := #0;
118   - end;
119   -end;
120   -
121   -
122   -// Encrypt a string and return the Base64 encoded result
123   -function EnCrypt(p_Data : String) : String;
124   -var
125   - l_Cipher : TDCP_rijndael;
126   - l_Data, l_Key, l_IV : string;
127   -begin
128   - Try
129   - // Pad Key, IV and Data with zeros as appropriate
130   - l_Key := PadWithZeros(v_CipherKey,KeySize);
131   - l_IV := PadWithZeros(v_IV,BlockSize);
132   - l_Data := PadWithZeros(p_Data,BlockSize);
133   -
134   - // Create the cipher and initialise according to the key length
135   - l_Cipher := TDCP_rijndael.Create(nil);
136   - if Length(v_CipherKey) <= 16 then
137   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
138   - else if Length(v_CipherKey) <= 24 then
139   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
140   - else
141   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
142   -
143   - // Encrypt the data
144   - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));
145   -
146   - // Free the cipher and clear sensitive information
147   - l_Cipher.Free;
148   - FillChar(l_Key[1],Length(l_Key),0);
149   -
150   - // Return the Base64 encoded result
151   - Result := Base64EncodeStr(l_Data);
152   - Except
153   - log_diario('Erro no Processo de Criptografia');
154   - End;
155   -end;
156   -
157   -function DeCrypt(p_Data : String) : String;
158   -var
159   - l_Cipher : TDCP_rijndael;
160   - l_Data, l_Key, l_IV : string;
161   -begin
162   - Try
163   - // Pad Key and IV with zeros as appropriate
164   - l_Key := PadWithZeros(v_CipherKey,KeySize);
165   - l_IV := PadWithZeros(v_IV,BlockSize);
166   -
167   - // Decode the Base64 encoded string
168   - l_Data := Base64DecodeStr(p_Data);
169   -
170   - // Create the cipher and initialise according to the key length
171   - l_Cipher := TDCP_rijndael.Create(nil);
172   - if Length(v_CipherKey) <= 16 then
173   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
174   - else if Length(v_CipherKey) <= 24 then
175   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
176   - else
177   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
178   -
179   - // Decrypt the data
180   - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));
181   -
182   - // Free the cipher and clear sensitive information
183   - l_Cipher.Free;
184   - FillChar(l_Key[1],Length(l_Key),0);
185   -
186   - // Return the result
187   - Result := l_Data;
188   - Except
189   - log_diario('Erro no Processo de Decriptografia');
190   - End;
191   -end;
192 84  
193 85 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
194 86 var v_strCipherOpenImploded : string;
... ... @@ -202,8 +94,8 @@ begin
202 94 Rewrite (v_DatFile);
203 95 Append(v_DatFile);
204 96  
205   - v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
206   - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
  97 + v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey);
  98 + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded);
207 99  
208 100 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
209 101  
... ... @@ -211,35 +103,6 @@ begin
211 103 except
212 104 end;
213 105 end;
214   -Function Explode(Texto, Separador : String) : TStrings;
215   -var
216   - strItem : String;
217   - ListaAuxUTILS : TStrings;
218   - NumCaracteres,
219   - TamanhoSeparador,
220   - I : Integer;
221   -Begin
222   - ListaAuxUTILS := TStringList.Create;
223   - strItem := '';
224   - NumCaracteres := Length(Texto);
225   - TamanhoSeparador := Length(Separador);
226   - I := 1;
227   - While I <= NumCaracteres Do
228   - Begin
229   - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then
230   - Begin
231   - if (I = NumCaracteres) then strItem := strItem + Texto[I];
232   - ListaAuxUTILS.Add(trim(strItem));
233   - strItem := '';
234   - I := I + (TamanhoSeparador-1);
235   - end
236   - Else
237   - strItem := strItem + Texto[I];
238   -
239   - I := I + 1;
240   - End;
241   - Explode := ListaAuxUTILS;
242   -end;
243 106  
244 107 Function CipherOpen(p_DatFileName : string) : TStrings;
245 108 var v_DatFile : TextFile;
... ... @@ -262,12 +125,12 @@ begin
262 125 Readln(v_DatFile,v_strCipherClosed);
263 126 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed);
264 127 CloseFile(v_DatFile);
265   - v_strCipherOpened:= DeCrypt(v_strCipherClosed);
  128 + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
266 129 end;
267 130 if (trim(v_strCipherOpened)<>'') then
268   - Result := explode(v_strCipherOpened,'=CacicIsFree=')
  131 + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey)
269 132 else
270   - Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  133 + 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);
271 134  
272 135 if Result.Count mod 2 <> 0 then
273 136 Result.Add('');
... ... @@ -345,7 +208,7 @@ var RegEditGet: TRegistry;
345 208 begin
346 209 try
347 210 Result := '';
348   - ListaAuxGet := Explode(Chave, ');
  211 + ListaAuxGet := g_oCacic.explode(Chave, ');
349 212  
350 213 strRootKey := ListaAuxGet[0];
351 214 For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
... ... @@ -385,7 +248,7 @@ var
385 248 strDataArqLocal, strDataAtual, v_file_debugs : string;
386 249 begin
387 250 try
388   - v_file_debugs := p_path_cacic + '\Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
  251 + v_file_debugs := g_oCacic.getCacicPath + '\Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
389 252 FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
390 253 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile}
391 254  
... ... @@ -496,12 +359,12 @@ Begin
496 359 (strTripaDados <> '') Then
497 360 Begin
498 361 SetValorDatMemoria('Col_Undi.UVC', strTripaDados, v_tstrCipherOpened1);
499   - CipherClose(p_path_cacic + 'temp\col_undi.dat', v_tstrCipherOpened1);
  362 + CipherClose(g_oCacic.getCacicPath + 'temp\col_undi.dat', v_tstrCipherOpened1);
500 363 end
501 364 else
502 365 Begin
503 366 SetValorDatMemoria('Col_Undi.nada', 'nada', v_tstrCipherOpened1);
504   - CipherClose(p_path_cacic + 'temp\col_undi.dat', v_tstrCipherOpened1);
  367 + CipherClose(g_oCacic.getCacicPath + 'temp\col_undi.dat', v_tstrCipherOpened1);
505 368 End;
506 369  
507 370 // Caso exista a pasta ..temp/debugs, será criado o arquivo diário debug_<coletor>.txt
... ... @@ -517,69 +380,50 @@ Begin
517 380 Except
518 381 SetValorDatMemoria('Col_Undi.nada', 'nada', v_tstrCipherOpened1);
519 382 SetValorDatMemoria('Col_Undi.Fim', '99999999', v_tstrCipherOpened1);
520   - CipherClose(p_path_cacic + 'temp\col_undi.dat', v_tstrCipherOpened1);
  383 + CipherClose(g_oCacic.getCacicPath + 'temp\col_undi.dat', v_tstrCipherOpened1);
521 384 log_diario('Problema na coleta de informações de discos.');
522 385 End;
523 386 end;
524 387  
525   -const
526   - CACIC_APP_NAME = 'col_undi';
527   -
528   -var
529   - tstrTripa1 : TStrings;
530   - intAux : integer;
531   -
  388 +var v_path_cacic : String;
532 389 begin
533 390 g_oCacic := TCACIC.Create();
534 391  
535 392 if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
536 393 if (ParamCount>0) then
537   - Begin
538   - For intAux := 1 to ParamCount do
539   - Begin
540   - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then
541   - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux)))));
542   - End;
543   -
544   - if (trim(v_CipherKey)<>'') then
545   - Begin
546   -
547   - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
548   - tstrTripa1 := explode(ExtractFilePath(ParamStr(0)),'\');
549   - p_path_cacic := '';
550   - For intAux := 0 to tstrTripa1.Count -2 do
551   - begin
552   - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\';
553   - end;
554   -
555   - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave.
556   - v_IV := 'abcdefghijklmnop';
557   - v_DatFileName := p_path_cacic + '\cacic2.dat';
558   - v_tstrCipherOpened := TStrings.Create;
559   - v_tstrCipherOpened := CipherOpen(v_DatFileName);
560   -
561   - v_tstrCipherOpened1 := TStrings.Create;
562   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'temp\col_undi.dat');
563   -
564   - Try
565   - v_Debugs := false;
566   - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then
  394 + Begin
  395 + //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
  396 + tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\');
  397 + v_path_cacic := '';
  398 + For intAux := 0 to tstrTripa1.Count -2 do
  399 + begin
  400 + v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\';
  401 + end;
  402 +
  403 + v_tstrCipherOpened := TStrings.Create;
  404 + v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName);
  405 +
  406 + v_tstrCipherOpened1 := TStrings.Create;
  407 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_undi.dat');
  408 +
  409 + Try
  410 + v_Debugs := false;
  411 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
  412 + Begin
  413 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
567 414 Begin
568   - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
569   - Begin
570   - v_Debugs := true;
571   - log_diario('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
572   - End;
  415 + v_Debugs := true;
  416 + log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
573 417 End;
  418 + End;
574 419  
575   - Executa_Col_undi;
576   - Except
577   - SetValorDatMemoria('Col_Undi.nada', 'nada', v_tstrCipherOpened1);
578   - CipherClose(p_path_cacic + 'temp\col_undi.dat', v_tstrCipherOpened1);
579   - End;
580   - End;
  420 + Executa_Col_undi;
  421 + Except
  422 + SetValorDatMemoria('Col_Undi.nada', 'nada', v_tstrCipherOpened1);
  423 + CipherClose(g_oCacic.getCacicPath + 'temp\col_undi.dat', v_tstrCipherOpened1);
  424 + End;
581 425 End;
582 426  
583 427 g_oCacic.Free();
584   -
  428 +
585 429 end.
... ...
ger_cols/ger_cols.dpr
... ... @@ -44,83 +44,53 @@ uses
44 44 IniFiles,
45 45 Registry,
46 46 LibXmlParser in 'LibXmlParser.pas',
47   - DCPcrypt2,
48   - DCPrijndael,
49   - DCPbase64,
50 47 ZLibEx,
51   - md5,
52 48 CACIC_Library in '..\CACIC_Library.pas';
53 49  
54 50 {$APPTYPE CONSOLE}
55   -var p_path_cacic,
56   - v_scripter,
57   - p_Shell_Command,
58   - v_acao_gercols,
59   - v_Tamanho_Arquivo,
60   - v_Endereco_Servidor,
61   - v_Aux,
62   - strAux,
63   - endereco_servidor_cacic,
64   - v_ModulosOpcoes,
65   - v_CipherKey,
66   - v_IV,
67   - v_DatFileName,
68   - v_ResultCompress,
69   - v_ResultUnCompress,
70   - g_te_so : string;
71   -
72   -var v_Aguarde : TextFile;
73   -
74   -var CountUPD,
75   - intAux,
76   - intMontaBatch,
77   - intLoop : integer;
78   -
79   -var tstrTripa1,
80   - v_tstrCipherOpened,
81   - v_tstrCipherOpened1,
82   - tstringsAux : TStrings;
83   -
84   -var v_Debugs,
85   - l_cs_cipher,
86   - l_cs_compress,
87   - v_CS_AUTO_UPDATE : boolean;
88   -
89   -var BatchFile,
90   - Request_Ger_Cols : TStringList;
  51 +var
  52 + v_scripter,
  53 + p_Shell_Command,
  54 + v_acao_gercols,
  55 + v_Tamanho_Arquivo,
  56 + v_Endereco_Servidor,
  57 + v_Aux,
  58 + strAux,
  59 + endereco_servidor_cacic,
  60 + v_ModulosOpcoes,
  61 + v_ResultCompress,
  62 + v_ResultUnCompress : string;
91 63  
92 64 var
93   - g_oCacic: TCACIC;
  65 + v_Aguarde : TextFile;
94 66  
95   -// Some constants that are dependant on the cipher being used
96   -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
97   -const KeySize = 32; // 32 bytes = 256 bits
98   - BlockSize = 16; // 16 bytes = 128 bits
  67 +var
  68 + CountUPD,
  69 + intAux,
  70 + intMontaBatch,
  71 + intLoop : integer;
99 72  
100   -// Para cálculo de HASH de determinado arquivo.
101   -// Objetivo principal: Verificar autenticidade de agentes para trabalho cooperativo
102   -// Anderson Peterle - Dataprev/ES - 08/Maio/2008
103   -function GetFileHash(strFileName : String) : String;
104   -Begin
105   - Result := 'Arquivo "'+strFileName+'" Inexistente!';
106   - if (FileExists(strFileName)) then
107   - Result := MD5Print(MD5File(strFileName));
108   -End;
  73 +var
  74 + tstrTripa1,
  75 + v_tstrCipherOpened,
  76 + v_tstrCipherOpened1,
  77 + tstringsAux : TStrings;
109 78  
110   -// Pad a string with zeros so that it is a multiple of size
111   -function PadWithZeros(const str : string; size : integer) : string;
112 79 var
113   - origsize, i : integer;
114   -begin
115   - Result := str;
116   - origsize := Length(Result);
117   - if ((origsize mod size) <> 0) or (origsize = 0) then
118   - begin
119   - SetLength(Result,((origsize div size)+1)*size);
120   - for i := origsize+1 to Length(Result) do
121   - Result[i] := #0;
122   - end;
123   -end;
  80 + v_Debugs,
  81 + l_cs_cipher,
  82 + l_cs_compress,
  83 + v_CS_AUTO_UPDATE : boolean;
  84 +
  85 +var
  86 + BatchFile,
  87 + Request_Ger_Cols : TStringList;
  88 +
  89 +var
  90 + g_oCacic: TCACIC;
  91 +
  92 +const
  93 + CACIC_APP_NAME = 'ger_cols';
124 94  
125 95 procedure log_diario(strMsg : String);
126 96 var
... ... @@ -128,8 +98,8 @@ var
128 98 strDataArqLocal, strDataAtual : string;
129 99 begin
130 100 try
131   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
132   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
  101 + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  102 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
133 103 {$IOChecks off}
134 104 Reset(HistoricoLog); {Abre o arquivo texto}
135 105 {$IOChecks on}
... ... @@ -139,7 +109,7 @@ begin
139 109 Append(HistoricoLog);
140 110 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log <=======================');
141 111 end;
142   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
  112 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log')));
143 113 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
144 114 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
145 115 begin
... ... @@ -281,39 +251,8 @@ begin
281 251 log_DEBUG('XML Parser retornando: "'+Result+'" para Tag "'+Tag+'"');
282 252 end;
283 253  
284   -
285   -Function Explode(Texto, Separador : String) : TStrings;
286   -var
287   - strItem : String;
288   - ListaAuxUTILS : TStrings;
289   - NumCaracteres,
290   - TamanhoSeparador,
291   - I : Integer;
292   -Begin
293   - ListaAuxUTILS := TStringList.Create;
294   - strItem := '';
295   - NumCaracteres := Length(Texto);
296   - TamanhoSeparador := Length(Separador);
297   - I := 1;
298   - While I <= NumCaracteres Do
299   - Begin
300   - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then
301   - Begin
302   - if (I = NumCaracteres) then strItem := strItem + Texto[I];
303   - ListaAuxUTILS.Add(trim(strItem));
304   - strItem := '';
305   - I := I + (TamanhoSeparador-1);
306   - end
307   - Else
308   - strItem := strItem + Texto[I];
309   -
310   - I := I + 1;
311   - End;
312   - Explode := ListaAuxUTILS;
313   -end;
314   -
315 254 function StringtoHex(Data: string): string;
316   -var
  255 +var
317 256 i, i2: Integer;
318 257 s: string;
319 258 begin
... ... @@ -331,18 +270,6 @@ begin
331 270 Result := s;
332 271 end;
333 272  
334   -Function Implode(p_Array : TStrings ; p_Separador : String) : String;
335   -var intAux : integer;
336   -Begin
337   - strAux := '';
338   - For intAux := 0 To p_Array.Count -1 do
339   - Begin
340   - if (strAux<>'') then strAux := strAux + p_Separador;
341   - strAux := strAux + p_Array[intAux];
342   - End;
343   - Implode := strAux;
344   -end;
345   -
346 273 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings);
347 274 var v_Aux : string;
348 275 begin
... ... @@ -357,6 +284,7 @@ begin
357 284 p_tstrCipherOpened.Add(v_Aux);
358 285 End;
359 286 end;
  287 +
360 288 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
361 289 var intTamanhoLista,
362 290 intIndiceChave : integer;
... ... @@ -367,7 +295,7 @@ begin
367 295 if (intIndiceChave <> -1) then
368 296 Begin
369 297 intTamanhoLista := p_tstrCipherOpened.Count;
370   - log_DEBUG('GetValorDatMemoria - Tamanho da Lista: '+intToStr(intTamanhoLista));
  298 + log_DEBUG('GetValorDatMemoria - Tamanho da Lista: '+intToStr(intTamanhoLista));
371 299 if ((intIndiceChave + 1) < intTamanhoLista) then
372 300 Result := trim(p_tstrCipherOpened[intIndiceChave + 1])
373 301 else
... ... @@ -379,111 +307,6 @@ begin
379 307 log_DEBUG('GetValorDatMemoria - Retornando "'+Result+'"');
380 308 end;
381 309  
382   -// Encrypt a string and return the Base64 encoded result
383   -function EnCrypt(p_Data : String; p_Compress : Boolean) : String;
384   -var
385   - l_Cipher : TDCP_rijndael;
386   - l_Data,
387   - l_Key,
388   - l_IV,
389   - strAux : String;
390   -begin
391   - Try
392   - if l_cs_cipher then
393   - Begin
394   - // Pad Key, IV and Data with zeros as appropriate
395   - l_Key := PadWithZeros(v_CipherKey,KeySize);
396   - l_IV := PadWithZeros(v_IV,BlockSize);
397   - l_Data := PadWithZeros(trim(p_Data),BlockSize);
398   -
399   - //log_DEBUG('Encrypt - HEXA da CHAVE "'+v_CipherKey+'": "'+StringtoHex(l_Key)+'"');
400   - //log_DEBUG('Encrypt - HEXA do IV "'+v_IV+'": "'+StringtoHex(l_IV)+'"');
401   - //log_DEBUG('Encrypt - HEXA do DADO "'+trim(p_Data)+'": "'+StringtoHex(l_Data)+'"');
402   -
403   - // Create the cipher and initialise according to the key length
404   - l_Cipher := TDCP_rijndael.Create(nil);
405   - if Length(v_CipherKey) <= 16 then
406   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
407   - else if Length(v_CipherKey) <= 24 then
408   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
409   - else
410   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
411   -
412   - // Encrypt the data
413   - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));
414   -
415   - // Free the cipher and clear sensitive information
416   - l_Cipher.Free;
417   - FillChar(l_Key[1],Length(l_Key),0);
418   - log_DEBUG('EnCrypt - Criptografia(ATIVADA) de "'+p_Data+'" => "'+l_Data+'"');
419   - // Return the Base64 encoded result
420   -
421   - Result := trim(Base64EncodeStr(l_Data));
422   - End
423   - else
424   - Begin
425   - log_DEBUG('EnCrypt - Criptografia(DESATIVADA) de "'+p_Data+'"');
426   - Result := trim(p_Data);
427   - End;
428   - Except
429   - log_diario('EnCrypt - Erro no Processo de Criptografia');
430   - End;
431   - if (p_Compress) and (l_cs_compress) then
432   - Result := Compress(Result);
433   -end;
434   -
435   -function DeCrypt(p_Data : String ; p_DeCompress : Boolean) : String;
436   -var
437   - l_Cipher : TDCP_rijndael;
438   - l_Data, l_Key, l_IV, v_Data : string;
439   -begin
440   - Try
441   - v_Data := p_Data;
442   - if (p_DeCompress) and (l_cs_compress) then
443   - v_Data := DeCompress(p_Data);
444   -
445   - if l_cs_cipher then
446   - Begin
447   - // Pad Key and IV with zeros as appropriate
448   - l_Key := PadWithZeros(v_CipherKey,KeySize);
449   - l_IV := PadWithZeros(v_IV,BlockSize);
450   -
451   - // Decode the Base64 encoded string
452   - l_Data := Base64DecodeStr(trim(v_Data));
453   -
454   - //log_DEBUG('Decrypt - HEXA da CHAVE "'+v_CipherKey+'": "'+StringtoHex(l_Key)+'"');
455   - //log_DEBUG('Decrypt - HEXA do IV "'+v_IV+'": "'+StringtoHex(l_IV)+'"');
456   - //log_DEBUG('Decrypt - HEXA do DADO "'+trim(p_Data)+'": "'+StringtoHex(l_Data)+'"');
457   -
458   - // Create the cipher and initialise according to the key length
459   - l_Cipher := TDCP_rijndael.Create(nil);
460   - if Length(v_CipherKey) <= 16 then
461   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
462   - else if Length(v_CipherKey) <= 24 then
463   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
464   - else
465   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
466   -
467   - // Decrypt the data
468   - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));
469   -
470   - // Free the cipher and clear sensitive information
471   - l_Cipher.Free;
472   - FillChar(l_Key[1],Length(l_Key),0);
473   - log_DEBUG('DeCrypt - DeCriptografia(ATIVADA) de "'+v_Data+'" => "'+l_Data+'"');
474   - // Return the result
475   - Result := trim(RemoveZerosFimString(l_Data));
476   - End
477   - else
478   - Begin
479   - log_DEBUG('DeCrypt - DeCriptografia(DESATIVADA) de "'+v_Data+'"');
480   - Result := trim(v_Data);
481   - End;
482   - Except
483   - log_diario('DeCrypt - Erro no Processo de DeCriptografia. Dado = '+v_Data);
484   - End;
485   -end;
486   -
487 310 procedure Matar(v_dir,v_files: string);
488 311 var SearchRec: TSearchRec;
489 312 Result: Integer;
... ... @@ -525,19 +348,19 @@ begin
525 348 Append(v_DatFileDebug);
526 349 End;
527 350  
528   - v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
  351 + v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey);
529 352  
530 353 v_cs_cipher := l_cs_cipher;
531 354 l_cs_cipher := true;
532 355 log_DEBUG('Rotina de Fechamento do cacic2.dat ATIVANDO criptografia.');
533   - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded, false);
  356 + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded);
534 357  
535 358 l_cs_cipher := v_cs_cipher;
536 359 log_DEBUG('Rotina de Fechamento do cacic2.dat RESTAURANDO estado da criptografia.');
537 360 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
538 361 if v_Debugs then
539 362 Begin
540   - Writeln(v_DatFileDebug,StringReplace(v_strCipherOpenImploded,'=CacicIsFree=',#13#10,[rfReplaceAll]));
  363 + Writeln(v_DatFileDebug,StringReplace(v_strCipherOpenImploded,g_oCacic.getSeparatorKey,#13#10,[rfReplaceAll]));
541 364 CloseFile(v_DatFileDebug);
542 365 End;
543 366 CloseFile(v_DatFile);
... ... @@ -575,14 +398,14 @@ begin
575 398 v_cs_cipher := l_cs_cipher;
576 399 l_cs_cipher := true;
577 400 log_DEBUG('Rotina de Abertura do cacic2.dat ATIVANDO criptografia.');
578   - v_strCipherOpened:= DeCrypt(v_strCipherClosed,false);
  401 + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
579 402 l_cs_cipher := v_cs_cipher;
580 403 log_DEBUG('Rotina de Abertura do cacic2.dat RESTAURANDO estado da criptografia.');
581 404 end;
582 405 if (trim(v_strCipherOpened)<>'') then
583   - Result := explode(v_strCipherOpened,'=CacicIsFree=')
  406 + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey)
584 407 else
585   - Result := explode('Configs.ID_SO=CacicIsFree='+g_oCacic.getWindowsStrId()+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  408 + 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);
586 409  
587 410 if Result.Count mod 2 = 0 then
588 411 Result.Add('');
... ... @@ -591,13 +414,13 @@ end;
591 414  
592 415 procedure Apaga_Temps;
593 416 begin
594   - Matar(p_path_cacic + 'temp\','*.vbs');
595   - Matar(p_path_cacic + 'temp\','*.txt');
  417 + Matar(g_oCacic.getCacicPath + 'temp\','*.vbs');
  418 + Matar(g_oCacic.getCacicPath + 'temp\','*.txt');
596 419 end;
597 420  
598 421 procedure Finalizar(p_pausa:boolean);
599 422 Begin
600   - CipherClose(v_DatFileName, v_tstrCipherOpened);
  423 + CipherClose(g_oCacic.getDatFileName, v_tstrCipherOpened);
601 424 Apaga_Temps;
602 425 if p_pausa then sleep(2000); // Pausa de 2 segundos para conclusão de operações de arquivos.
603 426 End;
... ... @@ -730,7 +553,7 @@ var RegEditGet: TRegistry;
730 553 begin
731 554 try
732 555 Result := '';
733   - ListaAuxGet := Explode(Chave, ');
  556 + ListaAuxGet := g_oCacic.explode(Chave, ');
734 557  
735 558 strRootKey := ListaAuxGet[0];
736 559 For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
... ... @@ -770,7 +593,7 @@ var RegEditSet: TRegistry;
770 593 ListaAuxSet : TStrings;
771 594 I : Integer;
772 595 begin
773   - ListaAuxSet := Explode(Chave, ');
  596 + ListaAuxSet := g_oCacic.explode(Chave, ');
774 597 strRootKey := ListaAuxSet[0];
775 598 For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\';
776 599 strValue := ListaAuxSet[ListaAuxSet.Count - 1];
... ... @@ -814,7 +637,7 @@ var RegDelValorReg: TRegistry;
814 637 ListaAuxDel : TStrings;
815 638 I : Integer;
816 639 begin
817   - ListaAuxDel := Explode(Chave, ');
  640 + ListaAuxDel := g_oCacic.explode(Chave, ');
818 641 strRootKey := ListaAuxDel[0];
819 642 For I := 1 To ListaAuxDel.Count - 2 Do strKey := strKey + ListaAuxDel[I] + '\';
820 643 strValue := ListaAuxDel[ListaAuxDel.Count - 1];
... ... @@ -941,7 +764,7 @@ begin
941 764 Begin
942 765 Try
943 766 strAux := GetValorChaveRegEdit('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Last Domain');
944   - listaAux_GWG := Explode(strAux, ',');
  767 + listaAux_GWG := g_oCacic.explode(strAux, ',');
945 768 Result := Trim(listaAux_GWG[2]);
946 769 listaAux_GWG.Free;
947 770 Except
... ... @@ -984,8 +807,8 @@ var L1_GIR, L2_GIR : TStrings;
984 807 end;
985 808 begin
986 809 Try
987   - L1_GIR := Explode(IP_Computador, '.');
988   - L2_GIR := Explode(MascaraRede, '.');
  810 + L1_GIR := g_oCacic.explode(IP_Computador, '.');
  811 + L2_GIR := g_oCacic.explode(MascaraRede, '.');
989 812  
990 813 //Percorre cada um dos 4 octetos dos endereços
991 814 for i := 0 to 3 do
... ... @@ -1041,7 +864,7 @@ begin
1041 864 Result := '';
1042 865 if (p_SectionName <> '') then
1043 866 Begin
1044   - v_array_SectionName := explode(p_SectionName,'/');
  867 + v_array_SectionName := g_oCacic.explode(p_SectionName,'/');
1045 868 v_array_SectionName_Count := v_array_SectionName.Count;
1046 869 End
1047 870 else v_array_SectionName_Count := 0;
... ... @@ -1100,7 +923,7 @@ var
1100 923 strDataArqLocal, strDataAtual, v_file_debugs : string;
1101 924 begin
1102 925 try
1103   - v_file_debugs := p_path_cacic + '\Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
  926 + v_file_debugs := g_oCacic.getCacicPath + '\Temp\Debugs\debug_'+StringReplace(ExtractFileName(StrUpper(PChar(ParamStr(0)))),'.EXE','',[rfReplaceAll])+'.txt';
1104 927 FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
1105 928 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile}
1106 929  
... ... @@ -1177,16 +1000,15 @@ Begin
1177 1000 strAux := 'A.B.C.D'; // Apenas para forçar que o Gerente extraia via _SERVER[REMOTE_ADDR]
1178 1001  
1179 1002 // Tratamentos de valores para tráfego POST:
1180   - v_AuxRequest.Values['te_node_address'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1181   - v_AuxRequest.Values['id_so'] := StringReplace(EnCrypt(g_oCacic.getWindowsStrId() ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1182   - v_AuxRequest.Values['te_so'] := StringReplace(EnCrypt(g_te_so ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1183   - v_AuxRequest.Values['te_ip'] := StringReplace(EnCrypt(strAux ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1184   - v_AuxRequest.Values['id_ip_rede'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1185   - v_AuxRequest.Values['te_workgroup'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1186   - v_AuxRequest.Values['te_nome_computador']:= StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1187   - v_AuxRequest.Values['id_ip_estacao'] := StringReplace(EnCrypt(GetIP ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1188   - v_AuxRequest.Values['te_versao_cacic'] := StringReplace(EnCrypt(getVersionInfo(p_path_cacic + 'cacic2.exe') ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1189   - v_AuxRequest.Values['te_versao_gercols'] := StringReplace(EnCrypt(getVersionInfo(ParamStr(0)) ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1003 + v_AuxRequest.Values['te_node_address'] := StringReplace(g_oCacic.EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]);
  1004 + v_AuxRequest.Values['te_so'] := StringReplace(g_oCacic.EnCrypt(g_oCacic.getWindowsStrId() ),'+','<MAIS>',[rfReplaceAll]);
  1005 + v_AuxRequest.Values['te_ip'] := StringReplace(g_oCacic.EnCrypt(strAux ),'+','<MAIS>',[rfReplaceAll]);
  1006 + v_AuxRequest.Values['id_ip_rede'] := StringReplace(g_oCacic.EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]);
  1007 + v_AuxRequest.Values['te_workgroup'] := StringReplace(g_oCacic.EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' , v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]);
  1008 + v_AuxRequest.Values['te_nome_computador']:= StringReplace(g_oCacic.EnCrypt(GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]);
  1009 + v_AuxRequest.Values['id_ip_estacao'] := StringReplace(g_oCacic.EnCrypt(GetIP ),'+','<MAIS>',[rfReplaceAll]);
  1010 + v_AuxRequest.Values['te_versao_cacic'] := StringReplace(g_oCacic.EnCrypt(getVersionInfo(g_oCacic.getCacicPath + 'cacic2.exe') ),'+','<MAIS>',[rfReplaceAll]);
  1011 + v_AuxRequest.Values['te_versao_gercols'] := StringReplace(g_oCacic.EnCrypt(getVersionInfo(ParamStr(0)) ),'+','<MAIS>',[rfReplaceAll]);
1190 1012  
1191 1013 v_Endereco_WS := GetValorDatMemoria('Configs.Endereco_WS', v_tstrCipherOpened);
1192 1014 v_Endereco_Servidor := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened);
... ... @@ -1198,7 +1020,7 @@ Begin
1198 1020 End;
1199 1021  
1200 1022 if (trim(v_Endereco_Servidor)='') then
1201   - v_Endereco_Servidor := Trim(GetValorChaveRegIni('Configs','EnderecoServidor',p_path_cacic + 'cacic2.ini'));
  1023 + v_Endereco_Servidor := Trim(GetValorChaveRegIni('Configs','EnderecoServidor',g_oCacic.getCacicPath + 'cacic2.ini'));
1202 1024  
1203 1025 strEndereco := 'http://' + v_Endereco_Servidor + v_Endereco_WS + URL;
1204 1026  
... ... @@ -1223,9 +1045,9 @@ Begin
1223 1045 idHTTP1.ProxyParams.ProxyPort := 0;
1224 1046 idHTTP1.ReadTimeout := 0;
1225 1047 idHTTP1.RedirectMaximum := 15;
1226   - idHTTP1.Request.UserAgent := StringReplace(EnCrypt('AGENTE_CACIC',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1227   - idHTTP1.Request.Username := StringReplace(EnCrypt('USER_CACIC',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1228   - idHTTP1.Request.Password := StringReplace(EnCrypt('PW_CACIC',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1048 + idHTTP1.Request.UserAgent := StringReplace(g_oCacic.enCrypt('AGENTE_CACIC'),'+','<MAIS>',[rfReplaceAll]);
  1049 + idHTTP1.Request.Username := StringReplace(g_oCacic.enCrypt('USER_CACIC'),'+','<MAIS>',[rfReplaceAll]);
  1050 + idHTTP1.Request.Password := StringReplace(g_oCacic.enCrypt('PW_CACIC'),'+','<MAIS>',[rfReplaceAll]);
1229 1051 idHTTP1.Request.Accept := 'text/html, */*';
1230 1052 idHTTP1.Request.BasicAuthentication := true;
1231 1053 idHTTP1.Request.ContentLength := -1;
... ... @@ -1240,7 +1062,7 @@ Begin
1240 1062  
1241 1063 if v_Debugs then
1242 1064 Begin
1243   - Log_Debug('te_so => '+g_te_so);
  1065 + Log_Debug('te_so => '+g_oCacic.getWindowsStrId);
1244 1066 Log_Debug('Valores de REQUEST para envio ao Gerente WEB:');
1245 1067 for intAux := 0 to v_AuxRequest.count -1 do
1246 1068 Log_Debug('#'+inttostr(intAux)+': '+v_AuxRequest[intAux]);
... ... @@ -1295,7 +1117,7 @@ Begin
1295 1117  
1296 1118 strRetorno := ComunicaServidor('get_patrimonio.php', Request_Ger_Cols, '.');
1297 1119 SetValorDatMemoria('Patrimonio.Configs', strRetorno, v_tstrCipherOpened);
1298   - SetValorDatMemoria('Patrimonio.cs_abre_janela_patr', DeCrypt(XML_RetornaValor('cs_abre_janela_patr', strRetorno),true), v_tstrCipherOpened);
  1120 + SetValorDatMemoria('Patrimonio.cs_abre_janela_patr', g_oCacic.deCrypt(XML_RetornaValor('cs_abre_janela_patr', strRetorno)), v_tstrCipherOpened);
1299 1121  
1300 1122 Request_Ger_Cols.Free;
1301 1123  
... ... @@ -1360,11 +1182,11 @@ var intAux1, intAux2, intAux3, intAux4, v_conta, v_conta_EXCECOES : integer;
1360 1182  
1361 1183 Begin
1362 1184 Result := '';
1363   - tstrOR := Explode(p_tripa,';'); // OR
  1185 + tstrOR := g_oCacic.explode(p_tripa,';'); // OR
1364 1186  
1365 1187 for intAux1 := 0 to tstrOR.Count-1 Do
1366 1188 Begin
1367   - tstrAND := Explode(tstrOR[intAux1],','); // AND
  1189 + tstrAND := g_oCacic.explode(tstrOR[intAux1],','); // AND
1368 1190 for intAux2 := 0 to p_array_campos.Count-1 Do
1369 1191 Begin
1370 1192 v_conta := 0;
... ... @@ -1380,7 +1202,7 @@ Begin
1380 1202 v_conta_EXCECOES := 0;
1381 1203 if (p_excecao <> '') then
1382 1204 Begin
1383   - tstrEXCECOES := Explode(p_excecao,','); // Excecoes a serem tratadas
  1205 + tstrEXCECOES := g_oCacic.explode(p_excecao,','); // Excecoes a serem tratadas
1384 1206 for intAux4 := 0 to tstrEXCECOES.Count-1 Do
1385 1207 Begin
1386 1208 if (rat(tstrEXCECOES[intAux4],p_array_valores[intAux2]) > 0) then
... ... @@ -1483,7 +1305,7 @@ Begin
1483 1305 End
1484 1306 else
1485 1307 Begin
1486   - v_Dir_Temp := p_path_cacic + p_Dir_Temp;
  1308 + v_Dir_Temp := g_oCacic.getCacicPath + p_Dir_Temp;
1487 1309 End;
1488 1310  
1489 1311 v_versao_disponivel := '';
... ... @@ -1523,7 +1345,7 @@ Begin
1523 1345 End
1524 1346 else
1525 1347 Begin
1526   - strHashLocal := GetFileHash(p_Dir_Inst + p_File + '.exe');
  1348 + strHashLocal := g_oCacic.getFileHash(p_Dir_Inst + p_File + '.exe');
1527 1349 strHashRemoto := GetValorDatMemoria('Configs.TE_HASH_'+UpperCase(p_File), v_tstrCipherOpened);
1528 1350 // TESTE
1529 1351 //if (UpperCase(p_File) = 'GER_COLS') or (UpperCase(p_File) = 'CACIC2') then
... ... @@ -1577,22 +1399,13 @@ Begin
1577 1399 end;
1578 1400 Except
1579 1401 Begin
1580   - CriaTXT(p_path_cacic,'ger_erro');
  1402 + CriaTXT(g_oCacic.getCacicPath,'ger_erro');
1581 1403 SetValorDatMemoria('Erro_Fatal','PROBLEMAS COM ROTINA DE EXECUÇÃO DE UPDATES DE VERSÕES. Não foi possível baixar o módulo '+ p_Nome_Modulo + '.', v_tstrCipherOpened);
1582 1404 log_diario('PROBLEMAS COM ROTINA DE EXECUÇÃO DE UPDATES DE VERSÕES.');
1583 1405 End;
1584 1406 End;
1585 1407 End;
1586 1408  
1587   -
1588   -function PegaWinDir(Sender: TObject) : string;
1589   -var WinPath: array[0..MAX_PATH + 1] of char;
1590   -begin
1591   - GetWindowsDirectory(WinPath,MAX_PATH);
1592   - Result := WinPath
1593   -end;
1594   -
1595   -
1596 1409 function GetNetworkUserName : String;
1597 1410 // Gets the name of the user currently logged into the network on
1598 1411 // the local PC
... ... @@ -1744,15 +1557,14 @@ End;
1744 1557 procedure Patrimnio1Click(Sender: TObject);
1745 1558 begin
1746 1559 SetValorDatMemoria('Patrimonio.dt_ultima_renovacao_patrim','', v_tstrCipherOpened);
1747   - if ChecaAgente(p_path_cacic + 'modulos', 'ini_cols.exe') then
1748   - g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey +
1749   - ' /p_ModulosOpcoes=col_patr,wait,user#', CACIC_PROCESS_WAIT );
  1560 + if ChecaAgente(g_oCacic.getCacicPath + 'modulos', 'ini_cols.exe') then
  1561 + g_oCacic.createSampleProcess( g_oCacic.getCacicPath + 'modulos\ini_cols.exe /p_ModulosOpcoes=col_patr,wait,user#', CACIC_PROCESS_WAIT );
1750 1562  
1751   - if (FileExists(p_path_cacic + 'Temp\col_patr.dat')) then
  1563 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_patr.dat')) then
1752 1564 Begin
1753   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_patr.dat encontrado.');
  1565 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_patr.dat encontrado.');
1754 1566 v_acao_gercols := '* Preparando envio de informações de Patrimônio.';
1755   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_patr.dat');
  1567 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_patr.dat');
1756 1568  
1757 1569 // Armazeno dados para informações de coletas na data, via menu popup do Systray
1758 1570 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações Patrimoniais', v_tstrCipherOpened);
... ... @@ -1764,16 +1576,16 @@ begin
1764 1576 if (GetValorDatMemoria('Col_Patr.nada',v_tstrCipherOpened1)='') then
1765 1577 Begin
1766 1578 // Preparação para envio...
1767   - Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1768   - Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1769   - Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1770   - Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1771   - Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1772   - Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1773   - Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1774   - Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1775   - Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1776   - Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1579 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1580 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1581 + Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1582 + Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1583 + Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1584 + Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1585 + Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1586 + Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1587 + Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  1588 + Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
1777 1589  
1778 1590 if v_Debugs then
1779 1591 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -1808,7 +1620,7 @@ begin
1808 1620 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
1809 1621  
1810 1622 Request_Ger_Cols.Clear;
1811   - Matar(p_path_cacic+'Temp,'col_patr.dat');
  1623 + Matar(g_oCacic.getCacicPath+'Temp,'col_patr.dat');
1812 1624 End;
1813 1625 end;
1814 1626  
... ... @@ -1924,7 +1736,7 @@ Begin
1924 1736  
1925 1737 // Verifico comunicação com o Módulo Gerente WEB.
1926 1738 Request_SVG := TStringList.Create;
1927   - Request_SVG.Values['in_teste'] := StringReplace(EnCrypt('OK',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1739 + Request_SVG.Values['in_teste'] := StringReplace(g_oCacic.enCrypt('OK'),'+','<MAIS>',[rfReplaceAll]);
1928 1740  
1929 1741 v_acao_gercols := 'Preparando teste de comunicação com Módulo Gerente WEB.';
1930 1742  
... ... @@ -1946,11 +1758,11 @@ Begin
1946 1758 Seta_l_cs_cipher(strRetorno);
1947 1759 Seta_l_cs_compress(strRetorno);
1948 1760  
1949   - v_Aux := DeCrypt(XML_RetornaValor('te_serv_cacic', strRetorno),l_cs_compress);
  1761 + v_Aux := g_oCacic.deCrypt(XML_RetornaValor('te_serv_cacic', strRetorno));
1950 1762 if (v_te_serv_cacic <> v_Aux) and (v_Aux <> '') then
1951 1763 SetValorDatMemoria('Configs.EnderecoServidor',v_Aux, v_tstrCipherOpened);
1952 1764  
1953   - if (strRetorno <> '0') and (DeCrypt(XML_RetornaValor('te_rede_ok', strRetorno),l_cs_compress)<>'N') Then
  1765 + if (strRetorno <> '0') and (g_oCacic.deCrypt(XML_RetornaValor('te_rede_ok', strRetorno))<>'N') Then
1954 1766 Begin
1955 1767 v_acao_gercols := 'IP/Máscara usados: ' + v_tcpip.Adapter[v_index_ethernet].IPAddress[intAux1]+'/'+v_tcpip.Adapter[v_index_ethernet].IPAddressMask[intAux1]+' validados pelo Módulo Gerente WEB.';
1956 1768 te_ip := v_tcpip.Adapter[v_index_ethernet].IPAddress[intAux1];
... ... @@ -1968,17 +1780,17 @@ Begin
1968 1780 // Nova tentativa, preciso reinicializar o objeto devido aos restos da operação anterior... (Eu acho!) :)
1969 1781 Request_SVG.Free;
1970 1782 Request_SVG := TStringList.Create;
1971   - Request_SVG.Values['in_teste'] := StringReplace(EnCrypt('OK',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1783 + Request_SVG.Values['in_teste'] := StringReplace(g_oCacic.enCrypt('OK'),'+','<MAIS>',[rfReplaceAll]);
1972 1784 Try
1973 1785 strRetorno := ComunicaServidor('get_config.php', Request_SVG, 'Teste de comunicação com o Módulo Gerente WEB.');
1974 1786 Seta_l_cs_cipher(strRetorno);
1975 1787 Seta_l_cs_compress(strRetorno);
1976 1788  
1977   - v_Aux := DeCrypt(XML_RetornaValor('te_serv_cacic', strRetorno),l_cs_compress);
  1789 + v_Aux := g_oCacic.deCrypt(XML_RetornaValor('te_serv_cacic', strRetorno));
1978 1790 if (v_te_serv_cacic <> v_Aux) and (v_Aux <> '') then
1979 1791 SetValorDatMemoria('Configs.EnderecoServidor',v_Aux, v_tstrCipherOpened);
1980 1792  
1981   - if (strRetorno <> '0') and (DeCrypt(XML_RetornaValor('te_rede_ok', strRetorno),l_cs_compress)<>'N') Then
  1793 + if (strRetorno <> '0') and (g_oCacic.deCrypt(XML_RetornaValor('te_rede_ok', strRetorno))<>'N') Then
1982 1794 Begin
1983 1795 v_acao_gercols := 'IP validado pelo Módulo Gerente WEB.';
1984 1796 log_diario(v_acao_gercols);
... ... @@ -2013,19 +1825,19 @@ Begin
2013 1825 v_acao_gercols := 'Contabilizando necessidade de Updates...';
2014 1826  
2015 1827 // O valor "true" para o 5º parâmetro da função Ver_UPD informa para apenas verificar a necessidade de FTP do referido objeto.
2016   - CountUPD := CountUPD + Ver_UPD('ini_cols' ,'Inicializador de Coletas' ,p_path_cacic + 'modulos\','',true);
2017   - CountUPD := CountUPD + Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]) ,'Interpretador VBS' ,p_path_cacic + 'modulos\','',true);
2018   - CountUPD := CountUPD + Ver_UPD('chksis' ,'Verificador de Integridade do Sistema' ,PegaWinDir(nil)+'\','',true);
2019   - CountUPD := CountUPD + Ver_UPD('cacic2' ,'Agente Principal' ,p_path_cacic,'Temp',true);
2020   - CountUPD := CountUPD + Ver_UPD('srcacicsrv' ,'Suporte Remoto Seguro' ,p_path_cacic + 'modulos\','',true);
2021   - CountUPD := CountUPD + Ver_UPD('ger_cols' ,'Gerente de Coletas' ,p_path_cacic + 'modulos\','Temp',true);
2022   - CountUPD := CountUPD + Ver_UPD('col_anvi' ,'Coletor de Informações de Anti-Vírus OfficeScan' ,p_path_cacic + 'modulos\','',true);
2023   - CountUPD := CountUPD + Ver_UPD('col_comp' ,'Coletor de Informações de Compartilhamentos' ,p_path_cacic + 'modulos\','',true);
2024   - CountUPD := CountUPD + Ver_UPD('col_hard' ,'Coletor de Informações de Hardware' ,p_path_cacic + 'modulos\','',true);
2025   - CountUPD := CountUPD + Ver_UPD('col_patr' ,'Coletor de Informações de Patrimônio/Loc.Fís.' ,p_path_cacic + 'modulos\','',true);
2026   - CountUPD := CountUPD + Ver_UPD('col_moni' ,'Coletor de Informações de Sistemas Monitorados' ,p_path_cacic + 'modulos\','',true);
2027   - CountUPD := CountUPD + Ver_UPD('col_soft' ,'Coletor de Informações de Softwares Básicos' ,p_path_cacic + 'modulos\','',true);
2028   - CountUPD := CountUPD + Ver_UPD('col_undi' ,'Coletor de Informações de Unidades de Disco' ,p_path_cacic + 'modulos\','',true);
  1828 + CountUPD := CountUPD + Ver_UPD('ini_cols' ,'Inicializador de Coletas' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1829 + CountUPD := CountUPD + Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]) ,'Interpretador VBS' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1830 + CountUPD := CountUPD + Ver_UPD('chksis' ,'Verificador de Integridade do Sistema' ,g_oCacic.getWinDir ,'',true);
  1831 + CountUPD := CountUPD + Ver_UPD('cacic2' ,'Agente Principal' ,g_oCacic.getCacicPath ,'Temp',true);
  1832 + CountUPD := CountUPD + Ver_UPD('srcacicsrv' ,'Suporte Remoto Seguro' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1833 + CountUPD := CountUPD + Ver_UPD('ger_cols' ,'Gerente de Coletas' ,g_oCacic.getCacicPath + 'modulos\','Temp',true);
  1834 + CountUPD := CountUPD + Ver_UPD('col_anvi' ,'Coletor de Informações de Anti-Vírus OfficeScan' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1835 + CountUPD := CountUPD + Ver_UPD('col_comp' ,'Coletor de Informações de Compartilhamentos' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1836 + CountUPD := CountUPD + Ver_UPD('col_hard' ,'Coletor de Informações de Hardware' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1837 + CountUPD := CountUPD + Ver_UPD('col_patr' ,'Coletor de Informações de Patrimônio/Loc.Fís.' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1838 + CountUPD := CountUPD + Ver_UPD('col_moni' ,'Coletor de Informações de Sistemas Monitorados' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1839 + CountUPD := CountUPD + Ver_UPD('col_soft' ,'Coletor de Informações de Softwares Básicos' ,g_oCacic.getCacicPath + 'modulos\','',true);
  1840 + CountUPD := CountUPD + Ver_UPD('col_undi' ,'Coletor de Informações de Unidades de Disco' ,g_oCacic.getCacicPath + 'modulos\','',true);
2029 1841  
2030 1842  
2031 1843  
... ... @@ -2042,8 +1854,8 @@ Begin
2042 1854 log_DEBUG('Preparando contato com módulo Gerente WEB para Downloads.');
2043 1855 v_acao_gercols := 'Contactando o módulo Gerente WEB: get_config.php...';
2044 1856 Request_SVG := TStringList.Create;
2045   - Request_SVG.Values['in_chkcacic'] := StringReplace(EnCrypt('chkcacic',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2046   - Request_SVG.Values['te_fila_ftp'] := StringReplace(EnCrypt('1',l_cs_compress),'+','<MAIS>',[rfReplaceAll]); // Indicará que o agente quer entrar no grupo para FTP
  1857 + Request_SVG.Values['in_chkcacic'] := StringReplace(g_oCacic.enCrypt('chkcacic'),'+','<MAIS>',[rfReplaceAll]);
  1858 + Request_SVG.Values['te_fila_ftp'] := StringReplace(g_oCacic.enCrypt('1'),'+','<MAIS>',[rfReplaceAll]); // Indicará que o agente quer entrar no grupo para FTP
2047 1859 //Request_SVG.Values['id_ip_estacao'] := EnCrypt(GetIP,l_cs_compress); // Informará o IP para registro na tabela redes_grupos_FTP
2048 1860  
2049 1861 log_DEBUG(v_acao_gercols + ' Parâmetros: in_chkcacic="'+Request_SVG.Values['in_chkcacic']+'", te_fila_ftp="'+Request_SVG.Values['te_fila_ftp']+'" e id_ip_estacao="'+Request_SVG.Values['id_ip_estacao']+'"');
... ... @@ -2051,17 +1863,19 @@ Begin
2051 1863 Seta_l_cs_cipher(strRetorno);
2052 1864 Seta_l_cs_compress(strRetorno);
2053 1865  
  1866 +
  1867 +
2054 1868 Request_SVG.Free;
2055 1869 if (strRetorno <> '0') Then
2056 1870 Begin
2057   - SetValorDatMemoria('Configs.TE_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_serv_updates' , strRetorno),true), v_tstrCipherOpened);
2058   - SetValorDatMemoria('Configs.NM_USUARIO_LOGIN_SERV_UPDATES',DeCrypt(XML_RetornaValor('nm_usuario_login_serv_updates' , strRetorno),true), v_tstrCipherOpened);
2059   - SetValorDatMemoria('Configs.TE_SENHA_LOGIN_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_senha_login_serv_updates' , strRetorno),true), v_tstrCipherOpened);
2060   - SetValorDatMemoria('Configs.TE_PATH_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_path_serv_updates' , strRetorno),true), v_tstrCipherOpened);
2061   - SetValorDatMemoria('Configs.NU_PORTA_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('nu_porta_serv_updates' , strRetorno),true), v_tstrCipherOpened);
2062   - SetValorDatMemoria('Configs.TE_FILA_FTP' ,DeCrypt(XML_RetornaValor('te_fila_ftp' , strRetorno),true), v_tstrCipherOpened);
2063   - SetValorDatMemoria('Configs.ID_FTP' ,DeCrypt(XML_RetornaValor('id_ftp' , strRetorno),true), v_tstrCipherOpened);
2064   - SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,DeCrypt(XML_RetornaValor('te_enderecos_mac_invalidos' , strRetorno),true), v_tstrCipherOpened);
  1871 + SetValorDatMemoria('Configs.TE_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('te_serv_updates' , strRetorno)), v_tstrCipherOpened);
  1872 + SetValorDatMemoria('Configs.NM_USUARIO_LOGIN_SERV_UPDATES',g_oCacic.DeCrypt(XML_RetornaValor('nm_usuario_login_serv_updates' , strRetorno)), v_tstrCipherOpened);
  1873 + SetValorDatMemoria('Configs.TE_SENHA_LOGIN_SERV_UPDATES' ,g_oCacic.DeCrypt(XML_RetornaValor('te_senha_login_serv_updates' , strRetorno)), v_tstrCipherOpened);
  1874 + SetValorDatMemoria('Configs.TE_PATH_SERV_UPDATES' ,g_oCacic.DeCrypt(XML_RetornaValor('te_path_serv_updates' , strRetorno)), v_tstrCipherOpened);
  1875 + SetValorDatMemoria('Configs.NU_PORTA_SERV_UPDATES' ,g_oCacic.DeCrypt(XML_RetornaValor('nu_porta_serv_updates' , strRetorno)), v_tstrCipherOpened);
  1876 + SetValorDatMemoria('Configs.TE_FILA_FTP' ,g_oCacic.DeCrypt(XML_RetornaValor('te_fila_ftp' , strRetorno)), v_tstrCipherOpened);
  1877 + SetValorDatMemoria('Configs.ID_FTP' ,g_oCacic.DeCrypt(XML_RetornaValor('id_ftp' , strRetorno)), v_tstrCipherOpened);
  1878 + SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,g_oCacic.DeCrypt(XML_RetornaValor('te_enderecos_mac_invalidos' , strRetorno)), v_tstrCipherOpened);
2065 1879 End;
2066 1880 End;
2067 1881  
... ... @@ -2077,23 +1891,23 @@ Begin
2077 1891 v_acao_gercols := 'Verificando versões do scripter e chksis';
2078 1892 log_DEBUG(''+v_acao_gercols);
2079 1893  
2080   - Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]),'Interpretador VBS' ,p_path_cacic + 'modulos\','',false);
2081   - Ver_UPD('chksis' ,'Verificador de Integridade do Sistema',PegaWinDir(nil)+'\' ,'',false);
  1894 + Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]),'Interpretador VBS' ,g_oCacic.getCacicPath + 'modulos\','',false);
  1895 + Ver_UPD('chksis' ,'Verificador de Integridade do Sistema',g_oCacic.getWinDir +'\' ,'',false);
2082 1896  
2083 1897 // O módulo de Suporte Remoto é opcional, através da opção Administração / Módulos
2084 1898 {
2085 1899 log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.');
2086 1900 // Caso encontre nova versão de srCACICsrv esta será gravada em modulos.
2087   - Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos,'',false);
  1901 + Ver_UPD('srcacicsrv','Suporte Remoto Seguro',g_oCacic.getCacicPath + 'modulos,'',false);
2088 1902 }
2089 1903  
2090 1904 // Verifico existência do chksis.ini
2091   - if not (FileExists(PegaWinDir(nil) + 'chksis.ini')) then
  1905 + if not (FileExists(g_oCacic.getWinDir + 'chksis.ini')) then
2092 1906 Begin
2093 1907 Try
2094 1908 v_acao_gercols := 'chksis.ini inexistente, recriando...';
2095   - tstrTripa1 := Explode(p_path_cacic,'\');
2096   - AssignFile(chksis_ini,PegaWinDir(nil) + '\chksis.ini'); {Associa o arquivo a uma variável do tipo TextFile}
  1909 + tstrTripa1 := g_oCacic.explode(g_oCacic.getCacicPath,'\');
  1910 + AssignFile(chksis_ini,g_oCacic.getWinDir + 'chksis.ini'); {Associa o arquivo a uma variável do tipo TextFile}
2097 1911 Rewrite(chksis_ini); // Recria o arquivo...
2098 1912 Append(chksis_ini);
2099 1913 Writeln(chksis_ini,'[Cacic2]');
... ... @@ -2115,7 +1929,7 @@ Begin
2115 1929 (te_nome_host='') or (te_serv_dhcp='' ) or (te_dns_primario='') or (te_wins_primario='') or
2116 1930 (te_wins_secundario='') then
2117 1931 Begin
2118   - v_nome_arquivo := p_path_cacic + 'Temp\ipconfig.txt';
  1932 + v_nome_arquivo := g_oCacic.getCacicPath + 'Temp\ipconfig.txt';
2119 1933 v_metodo_obtencao := 'WMI Object';
2120 1934 v_acao_gercols := 'Criando batch para obtenção de IPCONFIG via WMI...';
2121 1935 Try
... ... @@ -2148,17 +1962,17 @@ Begin
2148 1962 Batchfile.Add('IPConfigFile.Close');
2149 1963 Batchfile.Add('if v_ok = "OK" then');
2150 1964 Batchfile.Add(' Set FileSysOK = WScript.CreateObject("Scripting.FileSystemObject")');
2151   - Batchfile.Add(' Set IPConfigFileOK = FileSysOK.CreateTextFile("'+p_path_cacic + 'Temp\ipconfi1.txt", True)');
  1965 + Batchfile.Add(' Set IPConfigFileOK = FileSysOK.CreateTextFile("'+g_oCacic.getCacicPath + 'Temp\ipconfi1.txt", True)');
2152 1966 Batchfile.Add(' IPConfigFileOK.Close');
2153 1967 Batchfile.Add('end if');
2154 1968 Batchfile.Add('WScript.Quit');
2155   - Batchfile.SaveToFile(p_path_cacic + 'Temp\ipconfig.vbs');
  1969 + Batchfile.SaveToFile(g_oCacic.getCacicPath + 'Temp\ipconfig.vbs');
2156 1970 BatchFile.Free;
2157 1971 v_acao_gercols := 'Invocando execução de VBS para obtenção de IPCONFIG...';
2158   - log_DEBUG('Executando "'+p_path_cacic + 'modulos\' + v_scripter + ' //b ' + p_path_cacic + 'temp\ipconfig.vbs"');
  1972 + log_DEBUG('Executando "'+g_oCacic.getCacicPath + 'modulos\' + v_scripter + ' //b ' + g_oCacic.getCacicPath + 'temp\ipconfig.vbs"');
2159 1973  
2160   - if ChecaAgente(p_path_cacic + 'modulos', v_scripter) then
2161   - WinExec(PChar(p_path_cacic + 'modulos\' + v_scripter + ' //b ' + p_path_cacic + 'temp\ipconfig.vbs'), SW_HIDE);
  1974 + if ChecaAgente(g_oCacic.getCacicPath + 'modulos', v_scripter) then
  1975 + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\' + v_scripter + ' //b ' + g_oCacic.getCacicPath + 'temp\ipconfig.vbs'), SW_HIDE);
2162 1976 Except
2163 1977 Begin
2164 1978 log_diario('Erro na geração do ipconfig.txt pelo ' + v_metodo_obtencao+'.');
... ... @@ -2168,13 +1982,13 @@ Begin
2168 1982 // Para aguardar o processamento acima, caso aconteça
2169 1983 sleep(5000);
2170 1984  
2171   - v_Tamanho_Arquivo := Get_File_Size(p_path_cacic + 'Temp\ipconfig.txt',true);
2172   - if not (FileExists(p_path_cacic + 'Temp\ipconfi1.txt')) or (v_Tamanho_Arquivo='0') then // O arquivo ipconfig.txt foi gerado vazio, tentarei IPConfig ou WinIPcfg!
  1985 + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getCacicPath + 'Temp\ipconfig.txt',true);
  1986 + if not (FileExists(g_oCacic.getCacicPath + 'Temp\ipconfi1.txt')) or (v_Tamanho_Arquivo='0') then // O arquivo ipconfig.txt foi gerado vazio, tentarei IPConfig ou WinIPcfg!
2173 1987 Begin
2174 1988 Try
2175   - v_win_dir := PegaWinDir(nil);
2176   - v_win_dir_command := PegaWinDir(nil);
2177   - v_win_dir_ipcfg := PegaWinDir(nil);
  1989 + v_win_dir := g_oCacic.getWinDir;
  1990 + v_win_dir_command := g_oCacic.getWinDir;
  1991 + v_win_dir_ipcfg := g_oCacic.getWinDir;
2178 1992 v_dir_command := '';
2179 1993 v_dir_ipcfg := '';
2180 1994  
... ... @@ -2321,7 +2135,7 @@ Begin
2321 2135 v_conta_EXCECOES := 0;
2322 2136 if (v_enderecos_mac_invalidos <> '') then
2323 2137 Begin
2324   - tstrEXCECOES := Explode(v_enderecos_mac_invalidos,','); // Excecoes a serem tratadas
  2138 + tstrEXCECOES := g_oCacic.explode(v_enderecos_mac_invalidos,','); // Excecoes a serem tratadas
2325 2139 for intAux4 := 0 to tstrEXCECOES.Count-1 Do
2326 2140 Begin
2327 2141 if (rat(tstrEXCECOES[intAux4],v_mac_address) > 0) then
... ... @@ -2346,11 +2160,11 @@ Begin
2346 2160 log_DEBUG('Excluindo: "'+v_nome_arquivo+'"');
2347 2161 DeleteFile(v_nome_arquivo);
2348 2162  
2349   - v_acao_gercols := 'Excluindo arquivo '+p_path_cacic + 'Temp\ipconfi1.txt, usado na obtenção de IPCONFIG...';
2350   - Matar(p_path_cacic+'Temp\','ipconfi1.txt');
  2163 + v_acao_gercols := 'Excluindo arquivo '+g_oCacic.getCacicPath + 'Temp\ipconfi1.txt, usado na obtenção de IPCONFIG...';
  2164 + Matar(g_oCacic.getCacicPath+'Temp\','ipconfi1.txt');
2351 2165  
2352   - v_acao_gercols := 'Excluindo arquivo '+p_path_cacic + 'Temp\ipconfig.vbs, usado na obtenção de IPCONFIG...';
2353   - Matar(p_path_cacic+'Temp\','ipconfig.vbs');
  2166 + v_acao_gercols := 'Excluindo arquivo '+g_oCacic.getCacicPath + 'Temp\ipconfig.vbs, usado na obtenção de IPCONFIG...';
  2167 + Matar(g_oCacic.getCacicPath+'Temp\','ipconfig.vbs');
2354 2168 End;
2355 2169  
2356 2170 v_mascara := te_mascara;
... ... @@ -2406,10 +2220,10 @@ Begin
2406 2220  
2407 2221 if (ValorChaveRegistro <> '') then
2408 2222 Begin
2409   - tstrTripa1 := Explode(ValorChaveRegistro,'#');
  2223 + tstrTripa1 := g_oCacic.explode(ValorChaveRegistro,'#');
2410 2224 for intAux1 := 0 to tstrTripa1.Count-1 Do
2411 2225 Begin
2412   - tstrTripa2 := Explode(tstrTripa1[intAux1],',');
  2226 + tstrTripa2 := g_oCacic.explode(tstrTripa1[intAux1],',');
2413 2227 //Apenas os dois primeiros itens, id_aplicativo e dt_atualizacao
2414 2228 strTripa := strTripa + tstrTripa2[0] + ',' + tstrTripa2[1]+'#';
2415 2229 end;
... ... @@ -2418,7 +2232,7 @@ Begin
2418 2232 end; //While
2419 2233  
2420 2234 // Proposital, para forçar a chegada dos perfis, solução temporária...
2421   - Request_SVG.Values['te_tripa_perfis'] := StringReplace(EnCrypt('',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2235 + Request_SVG.Values['te_tripa_perfis'] := StringReplace(g_oCacic.enCrypt(''),'+','<MAIS>',[rfReplaceAll]);
2422 2236  
2423 2237 // Gero e armazeno uma palavra-chave e a envio ao Gerente WEB para atualização no BD.
2424 2238 // Essa palavra-chave será usada para o acesso ao Agente Principal
... ... @@ -2427,9 +2241,9 @@ Begin
2427 2241 SetValorDatMemoria('Configs.te_palavra_chave',strAux, v_tstrCipherOpened);
2428 2242  
2429 2243 // Verifico se srCACIC está em execução e em caso positivo entrego a chave atualizada
2430   - Matar(p_path_cacic+'Temp,'aguarde_SRCACIC.txt');
  2244 + Matar(g_oCacic.getCacicPath+'Temp,'aguarde_SRCACIC.txt');
2431 2245 sleep(2000);
2432   - if (FileExists(p_path_cacic + 'Temp\aguarde_SRCACIC.txt')) then
  2246 + if (FileExists(g_oCacic.getCacicPath + 'Temp\aguarde_SRCACIC.txt')) then
2433 2247 Begin
2434 2248 // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB
2435 2249 // Some cares about send and receive at Gerente WEB
... ... @@ -2437,14 +2251,14 @@ Begin
2437 2251 v_Aux := StringReplace(v_Aux ,'"' ,'<AD>' ,[rfReplaceAll]);
2438 2252 v_Aux := StringReplace(v_Aux ,'''','<AS>' ,[rfReplaceAll]);
2439 2253 v_Aux := StringReplace(v_Aux ,'\' ,'<BarrInv>' ,[rfReplaceAll]);
2440   - v_Aux := StringReplace(EnCrypt(v_Aux,l_cs_compress) ,'+' ,'<MAIS>' ,[rfReplaceAll]);
  2254 + v_Aux := StringReplace(g_oCacic.enCrypt(v_Aux) ,'+' ,'<MAIS>' ,[rfReplaceAll]);
2441 2255  
2442   - log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']' );
2443   - WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']'),SW_NORMAL);
  2256 + log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']' );
  2257 + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']'),SW_NORMAL);
2444 2258 End;
2445 2259  
2446 2260  
2447   - Request_SVG.Values['te_palavra_chave'] := EnCrypt(strAux,l_cs_compress);
  2261 + Request_SVG.Values['te_palavra_chave'] := g_oCacic.enCrypt(strAux);
2448 2262 v_te_serv_cacic := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened);
2449 2263  
2450 2264 strRetorno := ComunicaServidor('get_config.php', Request_SVG, v_mensagem_log);
... ... @@ -2455,7 +2269,7 @@ Begin
2455 2269 // A versão com compressão do Módulo Gerente WEB retornará o valor cs_compress=1(Quando receber "1") ou cs_compress=2(Quando receber "3")
2456 2270 Seta_l_cs_compress(strRetorno);
2457 2271  
2458   - v_te_serv_cacic := DeCrypt(XML_RetornaValor('te_serv_cacic',strRetorno),true);
  2272 + v_te_serv_cacic := g_oCacic.deCrypt(XML_RetornaValor('te_serv_cacic',strRetorno));
2459 2273  
2460 2274 if (strRetorno <> '0') and
2461 2275 (v_te_serv_cacic<>'') and
... ... @@ -2471,7 +2285,7 @@ Begin
2471 2285 // Solicito do servidor a configuração que foi definida pelo administrador do CACIC.
2472 2286 Request_SVG.Free;
2473 2287 Request_SVG := TStringList.Create;
2474   - Request_SVG.Values['te_tripa_perfis'] := StringReplace(EnCrypt('',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2288 + Request_SVG.Values['te_tripa_perfis'] := StringReplace(g_oCacic.enCrypt(''),'+','<MAIS>',[rfReplaceAll]);
2475 2289 strRetorno := ComunicaServidor('get_config.php', Request_SVG, v_mensagem_log);
2476 2290 Seta_l_cs_cipher(strRetorno);
2477 2291 Seta_l_cs_compress(strRetorno);
... ... @@ -2481,7 +2295,7 @@ Begin
2481 2295  
2482 2296 if (strRetorno <> '0') Then
2483 2297 Begin
2484   - ValorRetornado := DeCrypt(XML_RetornaValor('SISTEMAS_MONITORADOS_PERFIS', strRetorno),true);
  2298 + ValorRetornado := g_oCacic.deCrypt(XML_RetornaValor('SISTEMAS_MONITORADOS_PERFIS', strRetorno));
2485 2299 log_DEBUG('Valor Retornado para Sistemas Monitorados: "'+ValorRetornado+'"');
2486 2300 IF (ValorRetornado <> '') then
2487 2301 Begin
... ... @@ -2499,18 +2313,18 @@ Begin
2499 2313 end;
2500 2314  
2501 2315 intAux4 := 0;
2502   - tstrTripa3 := Explode(ValorRetornado,'#');
  2316 + tstrTripa3 := g_oCacic.explode(ValorRetornado,'#');
2503 2317 for intAux3 := 0 to tstrTripa3.Count-1 Do
2504 2318 Begin
2505 2319 strAux3 := 'SIS' + trim(inttostr(intAux4));
2506   - tstrTripa4 := Explode(tstrTripa3[intAux3],',');
  2320 + tstrTripa4 := g_oCacic.explode(tstrTripa3[intAux3],',');
2507 2321 while strAux3 <> '' do
2508 2322 begin
2509 2323 intAux4 := intAux4 + 1;
2510 2324 strAux3 := GetValorDatMemoria('Coletas.SIS' + trim(inttostr(intAux4)), v_tstrCipherOpened);
2511 2325 if (trim(strAux3)<>'') then
2512 2326 Begin
2513   - tstrTripa5 := Explode(strAux3,',');
  2327 + tstrTripa5 := g_oCacic.explode(strAux3,',');
2514 2328 if (tstrTripa5[0] = tstrTripa4[0]) then strAux3 := '';
2515 2329 End;
2516 2330 end;
... ... @@ -2525,62 +2339,62 @@ Begin
2525 2339 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2526 2340 //Gravação no CACIC2.DAT dos valores de REDE, COMPUTADOR e EXECUÇÃO obtidos, para consulta pelos outros módulos...
2527 2341 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2528   - SetValorDatMemoria('Configs.CS_AUTO_UPDATE' ,UpperCase(DeCrypt(XML_RetornaValor('cs_auto_update' , strRetorno),true)), v_tstrCipherOpened);
2529   - SetValorDatMemoria('Configs.CS_COLETA_HARDWARE' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_hardware' , strRetorno),true)), v_tstrCipherOpened);
2530   - SetValorDatMemoria('Configs.CS_COLETA_SOFTWARE' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_software' , strRetorno),true)), v_tstrCipherOpened);
2531   - SetValorDatMemoria('Configs.CS_COLETA_MONITORADO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_monitorado' , strRetorno),true)), v_tstrCipherOpened);
2532   - SetValorDatMemoria('Configs.CS_COLETA_OFFICESCAN' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_officescan' , strRetorno),true)), v_tstrCipherOpened);
2533   - SetValorDatMemoria('Configs.CS_COLETA_COMPARTILHAMENTOS' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_compart' , strRetorno),true)), v_tstrCipherOpened);
2534   - SetValorDatMemoria('Configs.CS_COLETA_UNID_DISC' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_unid_disc' , strRetorno),true)), v_tstrCipherOpened);
2535   - SetValorDatMemoria('Configs.CS_COLETA_PATRIMONIO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_patrimonio' , strRetorno),true)), v_tstrCipherOpened);
2536   - SetValorDatMemoria('Configs.CS_SUPORTE_REMOTO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_suporte_remoto' , strRetorno),true)), v_tstrCipherOpened);
2537   - SetValorDatMemoria('Configs.DT_VERSAO_CACIC2_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_cacic2_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2538   - SetValorDatMemoria('Configs.TE_HASH_CACIC2' ,DeCrypt(XML_RetornaValor('te_hash_cacic2' , strRetorno),true) , v_tstrCipherOpened);
2539   - SetValorDatMemoria('Configs.DT_VERSAO_GER_COLS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_ger_cols_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2540   - SetValorDatMemoria('Configs.TE_HASH_GER_COLS' ,DeCrypt(XML_RetornaValor('te_hash_ger_cols' , strRetorno),true) , v_tstrCipherOpened);
2541   - SetValorDatMemoria('Configs.DT_VERSAO_CHKSIS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_chksis_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2542   - SetValorDatMemoria('Configs.TE_HASH_CHKSIS' ,DeCrypt(XML_RetornaValor('te_hash_chksis' , strRetorno),true) , v_tstrCipherOpened);
2543   - SetValorDatMemoria('Configs.DT_VERSAO_COL_ANVI_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_anvi_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2544   - SetValorDatMemoria('Configs.TE_HASH_COL_ANVI' ,DeCrypt(XML_RetornaValor('te_hash_col_anvi' , strRetorno),true) , v_tstrCipherOpened);
2545   - SetValorDatMemoria('Configs.DT_VERSAO_COL_COMP_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_comp_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2546   - SetValorDatMemoria('Configs.TE_HASH_COL_COMP' ,DeCrypt(XML_RetornaValor('te_hash_col_comp' , strRetorno),true) , v_tstrCipherOpened);
2547   - SetValorDatMemoria('Configs.DT_VERSAO_COL_HARD_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_hard_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2548   - SetValorDatMemoria('Configs.TE_HASH_COL_HARD' ,DeCrypt(XML_RetornaValor('te_hash_col_hard' , strRetorno),true) , v_tstrCipherOpened);
2549   - SetValorDatMemoria('Configs.DT_VERSAO_COL_MONI_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_moni_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2550   - SetValorDatMemoria('Configs.TE_HASH_COL_MONI' ,DeCrypt(XML_RetornaValor('te_hash_col_moni' , strRetorno),true) , v_tstrCipherOpened);
2551   - SetValorDatMemoria('Configs.DT_VERSAO_COL_PATR_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_patr_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2552   - SetValorDatMemoria('Configs.TE_HASH_COL_PATR' ,DeCrypt(XML_RetornaValor('te_hash_col_patr' , strRetorno),true) , v_tstrCipherOpened);
2553   - SetValorDatMemoria('Configs.DT_VERSAO_COL_SOFT_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_soft_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2554   - SetValorDatMemoria('Configs.TE_HASH_COL_SOFT' ,DeCrypt(XML_RetornaValor('te_hash_col_soft' , strRetorno),true) , v_tstrCipherOpened);
2555   - SetValorDatMemoria('Configs.DT_VERSAO_COL_UNDI_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_col_undi_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2556   - SetValorDatMemoria('Configs.TE_HASH_COL_UNDI' ,DeCrypt(XML_RetornaValor('te_hash_col_undi' , strRetorno),true) , v_tstrCipherOpened);
2557   - SetValorDatMemoria('Configs.DT_VERSAO_INI_COLS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_ini_cols_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2558   - SetValorDatMemoria('Configs.TE_HASH_INI_COLS' ,DeCrypt(XML_RetornaValor('te_hash_ini_cols' , strRetorno),true) , v_tstrCipherOpened);
2559   - SetValorDatMemoria('Configs.DT_VERSAO_INI_COLS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_ini_cols_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2560   - SetValorDatMemoria('Configs.TE_HASH_SRCACICSRV' ,DeCrypt(XML_RetornaValor('te_hash_srcacicsrv' , strRetorno),true) , v_tstrCipherOpened);
2561   - SetValorDatMemoria('Configs.DT_VERSAO_SRCACICSRV_DISPONIVEL',DeCrypt(XML_RetornaValor('dt_versao_srcacicsrv_disponivel' , strRetorno),true) , v_tstrCipherOpened);
2562   - SetValorDatMemoria('Configs.TE_HASH_'+StringReplace(v_scripter,'.exe','',[rfReplaceAll]),DeCrypt(XML_RetornaValor('te_hash_'+StringReplace(v_scripter,'.exe','',[rfReplaceAll]),strRetorno),true) , v_tstrCipherOpened);
2563   - SetValorDatMemoria('Configs.TE_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_serv_updates' , strRetorno),true) , v_tstrCipherOpened);
2564   - SetValorDatMemoria('Configs.NU_PORTA_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('nu_porta_serv_updates' , strRetorno),true) , v_tstrCipherOpened);
2565   - SetValorDatMemoria('Configs.TE_PATH_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_path_serv_updates' , strRetorno),true) , v_tstrCipherOpened);
2566   - SetValorDatMemoria('Configs.NM_USUARIO_LOGIN_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('nm_usuario_login_serv_updates' , strRetorno),true) , v_tstrCipherOpened);
2567   - SetValorDatMemoria('Configs.TE_SENHA_LOGIN_SERV_UPDATES' ,DeCrypt(XML_RetornaValor('te_senha_login_serv_updates' , strRetorno),true) , v_tstrCipherOpened);
2568   - SetValorDatMemoria('Configs.IN_EXIBE_ERROS_CRITICOS' ,UpperCase(DeCrypt(XML_RetornaValor('in_exibe_erros_criticos' , strRetorno),true)), v_tstrCipherOpened);
2569   - SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,DeCrypt(XML_RetornaValor('te_senha_adm_agente' , strRetorno),true) , v_tstrCipherOpened);
2570   - SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,DeCrypt(XML_RetornaValor('nu_intervalo_renovacao_patrim' , strRetorno),true) , v_tstrCipherOpened);
2571   - SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,DeCrypt(XML_RetornaValor('nu_intervalo_exec' , strRetorno),true) , v_tstrCipherOpened);
2572   - SetValorDatMemoria('Configs.NU_EXEC_APOS' ,DeCrypt(XML_RetornaValor('nu_exec_apos' , strRetorno),true) , v_tstrCipherOpened);
2573   - SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,UpperCase(DeCrypt(XML_RetornaValor('in_exibe_bandeja' , strRetorno),true)), v_tstrCipherOpened);
2574   - SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,DeCrypt(XML_RetornaValor('te_janelas_excecao' , strRetorno),true) , v_tstrCipherOpened);
2575   - SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,DeCrypt(XML_RetornaValor('te_enderecos_mac_invalidos' , strRetorno),true) , v_tstrCipherOpened);
2576   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada' , strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2577   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_ANVI' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_anvi', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2578   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_COMP' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_comp', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2579   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_HARD' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_hard', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2580   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_MONI' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_moni', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2581   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_PATR' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_patr', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2582   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_SOFT' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_soft', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2583   - SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_UNDI' ,stringreplace(stringreplace(stringreplace(DeCrypt(XML_RetornaValor('dt_hr_coleta_forcada_undi', strRetorno),true),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2342 + SetValorDatMemoria('Configs.CS_AUTO_UPDATE' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_auto_update' , strRetorno))), v_tstrCipherOpened);
  2343 + SetValorDatMemoria('Configs.CS_COLETA_HARDWARE' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_hardware' , strRetorno))), v_tstrCipherOpened);
  2344 + SetValorDatMemoria('Configs.CS_COLETA_SOFTWARE' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_software' , strRetorno))), v_tstrCipherOpened);
  2345 + SetValorDatMemoria('Configs.CS_COLETA_MONITORADO' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_monitorado' , strRetorno))), v_tstrCipherOpened);
  2346 + SetValorDatMemoria('Configs.CS_COLETA_OFFICESCAN' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_officescan' , strRetorno))), v_tstrCipherOpened);
  2347 + SetValorDatMemoria('Configs.CS_COLETA_COMPARTILHAMENTOS' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_compart' , strRetorno))), v_tstrCipherOpened);
  2348 + SetValorDatMemoria('Configs.CS_COLETA_UNID_DISC' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_unid_disc' , strRetorno))), v_tstrCipherOpened);
  2349 + SetValorDatMemoria('Configs.CS_COLETA_PATRIMONIO' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_coleta_patrimonio' , strRetorno))), v_tstrCipherOpened);
  2350 + SetValorDatMemoria('Configs.CS_SUPORTE_REMOTO' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('cs_suporte_remoto' , strRetorno))), v_tstrCipherOpened);
  2351 + SetValorDatMemoria('Configs.DT_VERSAO_CACIC2_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_cacic2_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2352 + SetValorDatMemoria('Configs.TE_HASH_CACIC2' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_cacic2' , strRetorno)) , v_tstrCipherOpened);
  2353 + SetValorDatMemoria('Configs.DT_VERSAO_GER_COLS_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_ger_cols_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2354 + SetValorDatMemoria('Configs.TE_HASH_GER_COLS' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_ger_cols' , strRetorno)) , v_tstrCipherOpened);
  2355 + SetValorDatMemoria('Configs.DT_VERSAO_CHKSIS_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_chksis_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2356 + SetValorDatMemoria('Configs.TE_HASH_CHKSIS' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_chksis' , strRetorno)) , v_tstrCipherOpened);
  2357 + SetValorDatMemoria('Configs.DT_VERSAO_COL_ANVI_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_anvi_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2358 + SetValorDatMemoria('Configs.TE_HASH_COL_ANVI' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_anvi' , strRetorno)) , v_tstrCipherOpened);
  2359 + SetValorDatMemoria('Configs.DT_VERSAO_COL_COMP_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_comp_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2360 + SetValorDatMemoria('Configs.TE_HASH_COL_COMP' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_comp' , strRetorno)) , v_tstrCipherOpened);
  2361 + SetValorDatMemoria('Configs.DT_VERSAO_COL_HARD_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_hard_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2362 + SetValorDatMemoria('Configs.TE_HASH_COL_HARD' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_hard' , strRetorno)) , v_tstrCipherOpened);
  2363 + SetValorDatMemoria('Configs.DT_VERSAO_COL_MONI_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_moni_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2364 + SetValorDatMemoria('Configs.TE_HASH_COL_MONI' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_moni' , strRetorno)) , v_tstrCipherOpened);
  2365 + SetValorDatMemoria('Configs.DT_VERSAO_COL_PATR_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_patr_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2366 + SetValorDatMemoria('Configs.TE_HASH_COL_PATR' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_patr' , strRetorno)) , v_tstrCipherOpened);
  2367 + SetValorDatMemoria('Configs.DT_VERSAO_COL_SOFT_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_soft_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2368 + SetValorDatMemoria('Configs.TE_HASH_COL_SOFT' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_soft' , strRetorno)) , v_tstrCipherOpened);
  2369 + SetValorDatMemoria('Configs.DT_VERSAO_COL_UNDI_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_col_undi_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2370 + SetValorDatMemoria('Configs.TE_HASH_COL_UNDI' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_col_undi' , strRetorno)) , v_tstrCipherOpened);
  2371 + SetValorDatMemoria('Configs.DT_VERSAO_INI_COLS_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_ini_cols_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2372 + SetValorDatMemoria('Configs.TE_HASH_INI_COLS' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_ini_cols' , strRetorno)) , v_tstrCipherOpened);
  2373 + SetValorDatMemoria('Configs.DT_VERSAO_INI_COLS_DISPONIVEL' ,g_oCacic.deCrypt(XML_RetornaValor('dt_versao_ini_cols_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2374 + SetValorDatMemoria('Configs.TE_HASH_SRCACICSRV' ,g_oCacic.deCrypt(XML_RetornaValor('te_hash_srcacicsrv' , strRetorno)) , v_tstrCipherOpened);
  2375 + SetValorDatMemoria('Configs.DT_VERSAO_SRCACICSRV_DISPONIVEL',g_oCacic.deCrypt(XML_RetornaValor('dt_versao_srcacicsrv_disponivel' , strRetorno)) , v_tstrCipherOpened);
  2376 + SetValorDatMemoria('Configs.TE_HASH_'+StringReplace(v_scripter,'.exe','',[rfReplaceAll]),g_oCacic.deCrypt(XML_RetornaValor('te_hash_'+StringReplace(v_scripter,'.exe','',[rfReplaceAll]),strRetorno)) , v_tstrCipherOpened);
  2377 + SetValorDatMemoria('Configs.TE_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('te_serv_updates' , strRetorno)) , v_tstrCipherOpened);
  2378 + SetValorDatMemoria('Configs.NU_PORTA_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('nu_porta_serv_updates' , strRetorno)) , v_tstrCipherOpened);
  2379 + SetValorDatMemoria('Configs.TE_PATH_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('te_path_serv_updates' , strRetorno)) , v_tstrCipherOpened);
  2380 + SetValorDatMemoria('Configs.NM_USUARIO_LOGIN_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('nm_usuario_login_serv_updates' , strRetorno)) , v_tstrCipherOpened);
  2381 + SetValorDatMemoria('Configs.TE_SENHA_LOGIN_SERV_UPDATES' ,g_oCacic.deCrypt(XML_RetornaValor('te_senha_login_serv_updates' , strRetorno)) , v_tstrCipherOpened);
  2382 + SetValorDatMemoria('Configs.IN_EXIBE_ERROS_CRITICOS' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('in_exibe_erros_criticos' , strRetorno))), v_tstrCipherOpened);
  2383 + SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,g_oCacic.deCrypt(XML_RetornaValor('te_senha_adm_agente' , strRetorno)) , v_tstrCipherOpened);
  2384 + SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,g_oCacic.deCrypt(XML_RetornaValor('nu_intervalo_renovacao_patrim' , strRetorno)) , v_tstrCipherOpened);
  2385 + SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,g_oCacic.deCrypt(XML_RetornaValor('nu_intervalo_exec' , strRetorno)) , v_tstrCipherOpened);
  2386 + SetValorDatMemoria('Configs.NU_EXEC_APOS' ,g_oCacic.deCrypt(XML_RetornaValor('nu_exec_apos' , strRetorno)) , v_tstrCipherOpened);
  2387 + SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('in_exibe_bandeja' , strRetorno))), v_tstrCipherOpened);
  2388 + SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,g_oCacic.deCrypt(XML_RetornaValor('te_janelas_excecao' , strRetorno)) , v_tstrCipherOpened);
  2389 + SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,g_oCacic.deCrypt(XML_RetornaValor('te_enderecos_mac_invalidos' , strRetorno)) , v_tstrCipherOpened);
  2390 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada' , strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2391 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_ANVI' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_anvi', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2392 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_COMP' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_comp', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2393 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_HARD' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_hard', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2394 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_MONI' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_moni', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2395 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_PATR' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_patr', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2396 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_SOFT' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_soft', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
  2397 + SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_UNDI' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_undi', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened);
2584 2398 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2585 2399 end;
2586 2400  
... ... @@ -2598,17 +2412,17 @@ Begin
2598 2412 End;
2599 2413  
2600 2414 Request_SVG := TStringList.Create;
2601   - Request_SVG.Values['te_mascara'] := StringReplace(EnCrypt(te_mascara,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2602   - Request_SVG.Values['te_gateway'] := StringReplace(EnCrypt(te_gateway,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2603   - Request_SVG.Values['te_serv_dhcp'] := StringReplace(EnCrypt(te_serv_dhcp,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2604   - Request_SVG.Values['te_dns_primario'] := StringReplace(EnCrypt(te_dns_primario,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2605   - Request_SVG.Values['te_dns_secundario'] := StringReplace(EnCrypt(te_dns_secundario,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2606   - Request_SVG.Values['te_wins_primario'] := StringReplace(EnCrypt(te_wins_primario,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2607   - Request_SVG.Values['te_wins_secundario'] := StringReplace(EnCrypt(te_wins_secundario,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2608   - Request_SVG.Values['te_nome_host'] := StringReplace(EnCrypt(te_nome_host,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2609   - Request_SVG.Values['te_dominio_dns'] := StringReplace(EnCrypt(te_dominio_dns,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2610   - Request_SVG.Values['te_origem_mac'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_ORIGEM_MAC', v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2611   - Request_SVG.Values['te_dominio_windows'] := StringReplace(EnCrypt(te_dominio_windows,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2415 + Request_SVG.Values['te_mascara'] := StringReplace(g_oCacic.enCrypt(te_mascara),'+','<MAIS>',[rfReplaceAll]);
  2416 + Request_SVG.Values['te_gateway'] := StringReplace(g_oCacic.enCrypt(te_gateway),'+','<MAIS>',[rfReplaceAll]);
  2417 + Request_SVG.Values['te_serv_dhcp'] := StringReplace(g_oCacic.enCrypt(te_serv_dhcp),'+','<MAIS>',[rfReplaceAll]);
  2418 + Request_SVG.Values['te_dns_primario'] := StringReplace(g_oCacic.enCrypt(te_dns_primario),'+','<MAIS>',[rfReplaceAll]);
  2419 + Request_SVG.Values['te_dns_secundario'] := StringReplace(g_oCacic.enCrypt(te_dns_secundario),'+','<MAIS>',[rfReplaceAll]);
  2420 + Request_SVG.Values['te_wins_primario'] := StringReplace(g_oCacic.enCrypt(te_wins_primario),'+','<MAIS>',[rfReplaceAll]);
  2421 + Request_SVG.Values['te_wins_secundario'] := StringReplace(g_oCacic.enCrypt(te_wins_secundario),'+','<MAIS>',[rfReplaceAll]);
  2422 + Request_SVG.Values['te_nome_host'] := StringReplace(g_oCacic.enCrypt(te_nome_host),'+','<MAIS>',[rfReplaceAll]);
  2423 + Request_SVG.Values['te_dominio_dns'] := StringReplace(g_oCacic.enCrypt(te_dominio_dns),'+','<MAIS>',[rfReplaceAll]);
  2424 + Request_SVG.Values['te_origem_mac'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('TcpIp.TE_ORIGEM_MAC', v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]);
  2425 + Request_SVG.Values['te_dominio_windows'] := StringReplace(g_oCacic.enCrypt(te_dominio_windows),'+','<MAIS>',[rfReplaceAll]);
2612 2426  
2613 2427 v_acao_gercols := 'Contactando módulo Gerente WEB: set_tcp_ip.php';
2614 2428  
... ... @@ -2653,17 +2467,17 @@ Begin
2653 2467 log_DEBUG('Opção /UpdatePrincipal recebida...');
2654 2468 // 15 segundos de tempo total até a execução do novo cacic2.exe
2655 2469 sleep(7000);
2656   - v_acao_gercols := 'Atualização do Agente Principal - Excluindo '+p_path_cacic + 'cacic2.exe';
2657   - Matar(p_path_cacic,'cacic2.exe');
  2470 + v_acao_gercols := 'Atualização do Agente Principal - Excluindo '+g_oCacic.getCacicPath + 'cacic2.exe';
  2471 + Matar(g_oCacic.getCacicPath,'cacic2.exe');
2658 2472 sleep(2000);
2659 2473  
2660   - v_acao_gercols := 'Atualização do Agente Principal - Copiando '+p_path_cacic + 'temp\cacic2.exe para '+p_path_cacic + 'cacic2.exe';
2661   - log_DEBUG('Copiando '+p_path_cacic + 'temp\cacic2.exe para '+p_path_cacic + 'cacic2.exe');
2662   - CopyFile(pChar(p_path_cacic + 'temp\cacic2.exe'),pChar(p_path_cacic + 'cacic2.exe'),FALSE {Fail if Exists});
  2474 + v_acao_gercols := 'Atualização do Agente Principal - Copiando '+g_oCacic.getCacicPath + 'temp\cacic2.exe para '+g_oCacic.getCacicPath + 'cacic2.exe';
  2475 + log_DEBUG('Copiando '+g_oCacic.getCacicPath + 'temp\cacic2.exe para '+g_oCacic.getCacicPath + 'cacic2.exe');
  2476 + CopyFile(pChar(g_oCacic.getCacicPath + 'temp\cacic2.exe'),pChar(g_oCacic.getCacicPath + 'cacic2.exe'),FALSE {Fail if Exists});
2663 2477 sleep(2000);
2664 2478  
2665   - v_acao_gercols := 'Atualização do Agente Principal - Excluindo '+p_path_cacic + 'temp\cacic2.exe';
2666   - Matar(p_path_cacic+'temp\','cacic2.exe');
  2479 + v_acao_gercols := 'Atualização do Agente Principal - Excluindo '+g_oCacic.getCacicPath + 'temp\cacic2.exe';
  2480 + Matar(g_oCacic.getCacicPath+'temp\','cacic2.exe');
2667 2481 sleep(2000);
2668 2482  
2669 2483 SetValorDatMemoria('Configs.NU_EXEC_APOS','12345', v_tstrCipherOpened); // Para que o Agente Principal comande a coleta logo após 1 minuto...
... ... @@ -2671,11 +2485,11 @@ Begin
2671 2485  
2672 2486 log_DEBUG('Invocando atualização do Agente Principal...');
2673 2487  
2674   - v_acao_gercols := 'Atualização do Agente Principal - Invocando '+p_path_cacic + 'cacic2.exe /atualizacao';
  2488 + v_acao_gercols := 'Atualização do Agente Principal - Invocando '+g_oCacic.getCacicPath + 'cacic2.exe /atualizacao';
2675 2489 Finalizar(false);
2676 2490  
2677   - if ChecaAgente(p_path_cacic, 'cacic2.exe') then
2678   - WinExec(PChar(p_path_cacic + 'cacic2.exe /atualizacao'), SW_MINIMIZE);
  2491 + if ChecaAgente(g_oCacic.getCacicPath, 'cacic2.exe') then
  2492 + WinExec(PChar(g_oCacic.getCacicPath + 'cacic2.exe /atualizacao'), SW_MINIMIZE);
2679 2493 Sair;
2680 2494 end;
2681 2495  
... ... @@ -2718,7 +2532,7 @@ Begin
2718 2532 log_DEBUG('Chamando Coletor de Patrimônio...');
2719 2533 Patrimnio1Click(Nil);
2720 2534 Finalizar(false);
2721   - CriaTXT(p_path_cacic+'temp','coletas');
  2535 + CriaTXT(g_oCacic.getCacicPath+'temp','coletas');
2722 2536 Sair;
2723 2537 End;
2724 2538  
... ... @@ -2729,7 +2543,7 @@ Begin
2729 2543 Batchfile := TStringList.Create;
2730 2544 Batchfile.Add('*** Simulação de cookie para cacic2.exe recarregar os valores de configurações ***');
2731 2545 // A existência deste arquivo forçará o Cacic2.exe a recarregar valores das configurações obtidas e gravadas no Cacic2.DAT
2732   - Batchfile.SaveToFile(p_path_cacic + 'Temp\reset.txt');
  2546 + Batchfile.SaveToFile(g_oCacic.getCacicPath + 'Temp\reset.txt');
2733 2547 BatchFile.Free;
2734 2548 log_DEBUG('Configurações apanhadas no módulo Gerente WEB. Retornando ao Agente Principal...');
2735 2549 Finalizar(false);
... ... @@ -2762,22 +2576,22 @@ Begin
2762 2576 // Caso encontre nova versão de cacic2.exe esta será gravada em temp e ocorrerá o autoupdate em sua próxima tentativa de chamada ao Ger_Cols.
2763 2577 v_acao_gercols := 'Verificando versão do Agente Principal';
2764 2578 log_diario('Verificando nova versão para módulo Principal.');
2765   - Ver_UPD('cacic2','Agente Principal',p_path_cacic,'Temp',false);
  2579 + Ver_UPD('cacic2','Agente Principal',g_oCacic.getCacicPath,'Temp',false);
2766 2580  
2767 2581 log_diario('Verificando nova versão para módulo Gerente de Coletas.');
2768 2582 // Caso encontre nova versão de Ger_Cols esta será gravada em temp e ocorrerá o autoupdate.
2769   - Ver_UPD('ger_cols','Gerente de Coletas',p_path_cacic + 'modulos,'Temp',false);
  2583 + Ver_UPD('ger_cols','Gerente de Coletas',g_oCacic.getCacicPath + 'modulos,'Temp',false);
2770 2584  
2771 2585 // O módulo de Suporte Remoto é opcional...
2772 2586 if (GetValorDatMemoria('Configs.CS_SUPORTE_REMOTO' , v_tstrCipherOpened) = 'S') then
2773 2587 Begin
2774 2588 log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.');
2775 2589 // Caso encontre nova versão de srCACICsrv esta será gravada em modulos.
2776   - Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos,'Modulos',false);
  2590 + Ver_UPD('srcacicsrv','Suporte Remoto Seguro',g_oCacic.getCacicPath + 'modulos,'Modulos',false);
2777 2591 End;
2778 2592  
2779   - if (FileExists(p_path_cacic + 'Temp\ger_cols.exe')) or
2780   - (FileExists(p_path_cacic + 'Temp\cacic2.exe')) then
  2593 + if (FileExists(g_oCacic.getCacicPath + 'Temp\ger_cols.exe')) or
  2594 + (FileExists(g_oCacic.getCacicPath + 'Temp\cacic2.exe')) then
2781 2595 Begin
2782 2596 log_diario('Finalizando... (Update em ± 1 minuto).');
2783 2597 Finalizar(false);
... ... @@ -2791,7 +2605,7 @@ Begin
2791 2605 (GetValorDatMemoria('Configs.CS_COLETA_OFFICESCAN' , v_tstrCipherOpened) = 'S') or
2792 2606 (GetValorDatMemoria('Configs.CS_COLETA_COMPARTILHAMENTOS', v_tstrCipherOpened) = 'S') or
2793 2607 (GetValorDatMemoria('Configs.CS_COLETA_UNID_DISC' , v_tstrCipherOpened) = 'S')) and
2794   - not FileExists(p_path_cacic + 'Temp\ger_cols.exe') then
  2608 + not FileExists(g_oCacic.getCacicPath + 'Temp\ger_cols.exe') then
2795 2609 begin
2796 2610 v_acao_gercols := 'Montando script de coletas';
2797 2611 // Monto o batch de coletas de acordo com as configurações
... ... @@ -2817,8 +2631,8 @@ Begin
2817 2631 else
2818 2632 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_PATR','N', v_tstrCipherOpened);
2819 2633  
2820   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_patr','Coletor de Informações de Patrimônio/Loc.Fís.',p_path_cacic + 'modulos\','',false);
2821   - if (FileExists(p_path_cacic + 'Modulos\col_patr.exe')) then
  2634 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_patr','Coletor de Informações de Patrimônio/Loc.Fís.',g_oCacic.getCacicPath + 'modulos\','',false);
  2635 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_patr.exe')) then
2822 2636 Begin
2823 2637 GetInfoPatrimonio;
2824 2638 // Só chamo o Coletor de Patrimônio caso haja alteração de localização(e esteja configurado no módulo gerente WEB a abertura automática da janela)
... ... @@ -2847,8 +2661,8 @@ Begin
2847 2661 else
2848 2662 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_ANVI','N', v_tstrCipherOpened);
2849 2663  
2850   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_anvi','Coletor de Informações de Anti-Vírus OfficeScan',p_path_cacic + 'modulos\','',false);
2851   - if (FileExists(p_path_cacic + 'Modulos\col_anvi.exe')) then
  2664 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_anvi','Coletor de Informações de Anti-Vírus OfficeScan',g_oCacic.getCacicPath + 'modulos\','',false);
  2665 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_anvi.exe')) then
2852 2666 Begin
2853 2667 intMontaBatch := 1;
2854 2668 v_ModulosOpcoes := v_ModulosOpcoes + 'col_anvi,nowait,system';
... ... @@ -2868,8 +2682,8 @@ Begin
2868 2682 else
2869 2683 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_COMP','N', v_tstrCipherOpened);
2870 2684  
2871   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_comp','Coletor de Informações de Compartilhamentos',p_path_cacic + 'modulos\','',false);
2872   - if (FileExists(p_path_cacic + 'Modulos\col_comp.exe')) then
  2685 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_comp','Coletor de Informações de Compartilhamentos',g_oCacic.getCacicPath + 'modulos\','',false);
  2686 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_comp.exe')) then
2873 2687 Begin
2874 2688 intMontaBatch := 1;
2875 2689 if (v_ModulosOpcoes<>'') then v_ModulosOpcoes := v_ModulosOpcoes + '#';
... ... @@ -2890,8 +2704,8 @@ Begin
2890 2704 else
2891 2705 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_HARD','N', v_tstrCipherOpened);
2892 2706  
2893   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_hard','Coletor de Informações de Hardware',p_path_cacic + 'modulos\','',false);
2894   - if (FileExists(p_path_cacic + 'Modulos\col_hard.exe')) then
  2707 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_hard','Coletor de Informações de Hardware',g_oCacic.getCacicPath + 'modulos\','',false);
  2708 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_hard.exe')) then
2895 2709 Begin
2896 2710 intMontaBatch := 1;
2897 2711 if (v_ModulosOpcoes<>'') then v_ModulosOpcoes := v_ModulosOpcoes + '#';
... ... @@ -2913,8 +2727,8 @@ Begin
2913 2727 else
2914 2728 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_MONI','N', v_tstrCipherOpened);
2915 2729  
2916   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_moni','Coletor de Informações de Sistemas Monitorados',p_path_cacic + 'modulos\','',false);
2917   - if (FileExists(p_path_cacic + 'Modulos\col_moni.exe')) then
  2730 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_moni','Coletor de Informações de Sistemas Monitorados',g_oCacic.getCacicPath + 'modulos\','',false);
  2731 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_moni.exe')) then
2918 2732 Begin
2919 2733 intMontaBatch := 1;
2920 2734 if (v_ModulosOpcoes<>'') then v_ModulosOpcoes := v_ModulosOpcoes + '#';
... ... @@ -2935,8 +2749,8 @@ Begin
2935 2749 else
2936 2750 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_SOFT','N', v_tstrCipherOpened);
2937 2751  
2938   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_soft','Coletor de Informações de Softwares Básicos',p_path_cacic + 'modulos\','',false);
2939   - if (FileExists(p_path_cacic + 'Modulos\col_soft.exe')) then
  2752 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_soft','Coletor de Informações de Softwares Básicos',g_oCacic.getCacicPath + 'modulos\','',false);
  2753 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_soft.exe')) then
2940 2754 Begin
2941 2755 intMontaBatch := 1;
2942 2756 if (v_ModulosOpcoes<>'') then v_ModulosOpcoes := v_ModulosOpcoes + '#';
... ... @@ -2957,8 +2771,8 @@ Begin
2957 2771 else
2958 2772 SetValorDatMemoria('Configs.IN_COLETA_FORCADA_UNDI','N', v_tstrCipherOpened);
2959 2773  
2960   - if (v_CS_AUTO_UPDATE) then Ver_UPD('col_undi','Coletor de Informações de Unidades de Disco',p_path_cacic + 'modulos\','',false);
2961   - if (FileExists(p_path_cacic + 'Modulos\col_undi.exe')) then
  2774 + if (v_CS_AUTO_UPDATE) then Ver_UPD('col_undi','Coletor de Informações de Unidades de Disco',g_oCacic.getCacicPath + 'modulos\','',false);
  2775 + if (FileExists(g_oCacic.getCacicPath + 'Modulos\col_undi.exe')) then
2962 2776 Begin
2963 2777 intMontaBatch := 1;
2964 2778 if (v_ModulosOpcoes<>'') then v_ModulosOpcoes := v_ModulosOpcoes + '#';
... ... @@ -2971,29 +2785,28 @@ Begin
2971 2785 (GetValorDatMemoria('Configs.ID_FTP',v_tstrCipherOpened)<>'') then
2972 2786 Begin
2973 2787 Request_Ger_Cols := TStringList.Create;
2974   - Request_Ger_Cols.Values['in_chkcacic'] := StringReplace(EnCrypt('chkcacic',l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
2975   - Request_Ger_Cols.Values['te_fila_ftp'] := StringReplace(EnCrypt('2',l_cs_compress),'+','<MAIS>',[rfReplaceAll]); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
2976   - Request_Ger_Cols.Values['id_ftp'] := StringReplace(EnCrypt(GetValorDatMemoria('Configs.ID_FTP',v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
  2788 + Request_Ger_Cols.Values['in_chkcacic'] := StringReplace(g_oCacic.enCrypt('chkcacic'),'+','<MAIS>',[rfReplaceAll]);
  2789 + Request_Ger_Cols.Values['te_fila_ftp'] := StringReplace(g_oCacic.enCrypt('2'),'+','<MAIS>',[rfReplaceAll]); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
  2790 + Request_Ger_Cols.Values['id_ftp'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Configs.ID_FTP',v_tstrCipherOpened)),'+','<MAIS>',[rfReplaceAll]); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
2977 2791 ComunicaServidor('get_config.php', Request_Ger_Cols, '>> Liberando Grupo FTP!...');
2978 2792 Request_Ger_Cols.Free;
2979 2793 SetValorDatMemoria('Configs.ID_FTP','', v_tstrCipherOpened)
2980 2794 End;
2981 2795 if (intMontaBatch > 0) then
2982 2796 Begin
2983   - Ver_UPD('ini_cols','Inicializador de Coletas',p_path_cacic + 'modulos,'',false);
  2797 + Ver_UPD('ini_cols','Inicializador de Coletas',g_oCacic.getCacicPath + 'modulos,'',false);
2984 2798 log_diario('Iniciando coletas.');
2985 2799 Finalizar(false);
2986   - Matar(p_path_cacic + 'temp\','*.dat');
2987   - CriaTXT(p_path_cacic+'temp','coletas');
2988   - g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey +
2989   - ' /p_ModulosOpcoes=' + v_ModulosOpcoes, CACIC_PROCESS_WAIT );
  2800 + Matar(g_oCacic.getCacicPath + 'temp\','*.dat');
  2801 + CriaTXT(g_oCacic.getCacicPath+'temp','coletas');
  2802 + g_oCacic.createSampleProcess( g_oCacic.getCacicPath + 'modulos\ini_cols.exe /p_ModulosOpcoes=' + v_ModulosOpcoes, CACIC_PROCESS_WAIT );
2990 2803 End;
2991 2804  
2992 2805 end
2993 2806 else
2994 2807 begin
2995   - if not FileExists(p_path_cacic + 'Temp\ger_cols.exe') and
2996   - not FileExists(p_path_cacic + 'modulos\ger_cols.exe') then
  2808 + if not FileExists(g_oCacic.getCacicPath + 'Temp\ger_cols.exe') and
  2809 + not FileExists(g_oCacic.getCacicPath + 'modulos\ger_cols.exe') then
2997 2810 log_diario('Módulo Gerente de Coletas inexistente.')
2998 2811 else log_diario('Nenhuma coleta configurada para essa subrede / estação / S.O.');
2999 2812 end;
... ... @@ -3001,7 +2814,7 @@ Begin
3001 2814 end;
3002 2815  
3003 2816 // Caso não existam os arquivos abaixo, será finalizado.
3004   - if (FileExists(p_path_cacic + 'Temp\coletas.txt')) or (FileExists(p_path_cacic + 'Temp\coletas.bat')) then
  2817 + if (FileExists(g_oCacic.getCacicPath + 'Temp\coletas.txt')) or (FileExists(g_oCacic.getCacicPath + 'Temp\coletas.bat')) then
3005 2818 begin
3006 2819 log_DEBUG('Encontrado indicador de Coletas - Realizando leituras...');
3007 2820 v_tstrCipherOpened1 := TStrings.Create;
... ... @@ -3010,11 +2823,11 @@ Begin
3010 2823 Request_Ger_Cols:=TStringList.Create;
3011 2824 intAux := 0;
3012 2825  
3013   - if (FileExists(p_path_cacic + 'Temp\col_anvi.dat')) then
  2826 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_anvi.dat')) then
3014 2827 Begin
3015   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_anvi.dat encontrado.');
  2828 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_anvi.dat encontrado.');
3016 2829 v_acao_gercols := '* Preparando envio de informações de Anti-Vírus.';
3017   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_anvi.dat');
  2830 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_anvi.dat');
3018 2831  
3019 2832 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3020 2833 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Anti-Vírus OfficeScan', v_tstrCipherOpened);
... ... @@ -3026,11 +2839,11 @@ Begin
3026 2839 if (GetValorDatMemoria('Col_Anvi.nada',v_tstrCipherOpened1)='') then
3027 2840 Begin
3028 2841 // Preparação para envio...
3029   - Request_Ger_Cols.Values['nu_versao_engine' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Anvi.nu_versao_engine' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3030   - Request_Ger_Cols.Values['nu_versao_pattern'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Anvi.nu_versao_pattern',v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3031   - Request_Ger_Cols.Values['dt_hr_instalacao' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Anvi.dt_hr_instalacao' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3032   - Request_Ger_Cols.Values['te_servidor' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Anvi.te_servidor' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3033   - Request_Ger_Cols.Values['in_ativo' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Anvi.in_ativo' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2842 + Request_Ger_Cols.Values['nu_versao_engine' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Anvi.nu_versao_engine' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2843 + Request_Ger_Cols.Values['nu_versao_pattern'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Anvi.nu_versao_pattern',v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2844 + Request_Ger_Cols.Values['dt_hr_instalacao' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Anvi.dt_hr_instalacao' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2845 + Request_Ger_Cols.Values['te_servidor' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Anvi.te_servidor' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2846 + Request_Ger_Cols.Values['in_ativo' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Anvi.in_ativo' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
3034 2847  
3035 2848 if v_Debugs then
3036 2849 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -3057,14 +2870,14 @@ Begin
3057 2870 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3058 2871  
3059 2872 Request_Ger_Cols.Clear;
3060   - Matar(p_path_cacic+'Temp,'col_anvi.dat');
  2873 + Matar(g_oCacic.getCacicPath+'Temp,'col_anvi.dat');
3061 2874 End;
3062 2875  
3063   - if (FileExists(p_path_cacic + 'Temp\col_comp.dat')) then
  2876 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_comp.dat')) then
3064 2877 Begin
3065   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_comp.dat encontrado.');
  2878 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_comp.dat encontrado.');
3066 2879 v_acao_gercols := '* Preparando envio de informações de Compartilhamentos.';
3067   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_comp.dat');
  2880 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_comp.dat');
3068 2881  
3069 2882 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3070 2883 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Compartilhamentos', v_tstrCipherOpened);
... ... @@ -3076,7 +2889,7 @@ Begin
3076 2889 if (GetValorDatMemoria('Col_Comp.nada',v_tstrCipherOpened1)='') then
3077 2890 Begin
3078 2891 // Preparação para envio...
3079   - Request_Ger_Cols.Values['CompartilhamentosLocais'] := StringReplace(EnCrypt(StringReplace(GetValorDatMemoria('Col_Comp.UVC',v_tstrCipherOpened1),'\','<BarrInv>',[rfReplaceAll]),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2892 + Request_Ger_Cols.Values['CompartilhamentosLocais'] := StringReplace(g_oCacic.enCrypt(StringReplace(GetValorDatMemoria('Col_Comp.UVC',v_tstrCipherOpened1),'\','<BarrInv>',[rfReplaceAll])),'+','<MAIS>',[rfReplaceAll]);
3080 2893 if v_Debugs then
3081 2894 Begin
3082 2895 log_DEBUG('Col_Comp.UVC => '+GetValorDatMemoria('Col_Comp.UVC',v_tstrCipherOpened1));
... ... @@ -3104,14 +2917,14 @@ Begin
3104 2917 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3105 2918  
3106 2919 Request_Ger_Cols.Clear;
3107   - Matar(p_path_cacic+'Temp,'col_comp.dat');
  2920 + Matar(g_oCacic.getCacicPath+'Temp,'col_comp.dat');
3108 2921 End;
3109 2922  
3110   - if (FileExists(p_path_cacic + 'Temp\col_hard.dat')) then
  2923 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_hard.dat')) then
3111 2924 Begin
3112   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_hard.dat encontrado.');
  2925 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_hard.dat encontrado.');
3113 2926 v_acao_gercols := '* Preparando envio de informações de Hardware.';
3114   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_hard.dat');
  2927 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_hard.dat');
3115 2928  
3116 2929 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3117 2930 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Hardware', v_tstrCipherOpened);
... ... @@ -3123,24 +2936,24 @@ Begin
3123 2936 if (GetValorDatMemoria('Col_Hard.nada',v_tstrCipherOpened1)='') then
3124 2937 Begin
3125 2938 // Preparação para envio...
3126   - Request_Ger_Cols.Values['te_Tripa_TCPIP' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_TCPIP' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3127   - Request_Ger_Cols.Values['te_Tripa_CPU' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_CPU' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3128   - Request_Ger_Cols.Values['te_Tripa_CDROM' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_CDROM' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3129   - Request_Ger_Cols.Values['te_placa_mae_fabricante' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_placa_mae_fabricante' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3130   - Request_Ger_Cols.Values['te_placa_mae_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_placa_mae_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3131   - Request_Ger_Cols.Values['qt_mem_ram' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.qt_mem_ram' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3132   - Request_Ger_Cols.Values['te_mem_ram_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_mem_ram_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3133   - Request_Ger_Cols.Values['te_bios_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_bios_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3134   - Request_Ger_Cols.Values['te_bios_data' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_bios_data' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3135   - Request_Ger_Cols.Values['te_bios_fabricante' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_bios_fabricante' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3136   - Request_Ger_Cols.Values['qt_placa_video_cores' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.qt_placa_video_cores' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3137   - Request_Ger_Cols.Values['te_placa_video_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_placa_video_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3138   - Request_Ger_Cols.Values['qt_placa_video_mem' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.qt_placa_video_mem' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3139   - Request_Ger_Cols.Values['te_placa_video_resolucao'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_placa_video_resolucao',v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3140   - Request_Ger_Cols.Values['te_placa_som_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_placa_som_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3141   - Request_Ger_Cols.Values['te_teclado_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_teclado_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3142   - Request_Ger_Cols.Values['te_mouse_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_mouse_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3143   - Request_Ger_Cols.Values['te_modem_desc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Hard.te_modem_desc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  2939 + Request_Ger_Cols.Values['te_Tripa_TCPIP' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_TCPIP' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2940 + Request_Ger_Cols.Values['te_Tripa_CPU' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_CPU' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2941 + Request_Ger_Cols.Values['te_Tripa_CDROM' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_Tripa_CDROM' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2942 + Request_Ger_Cols.Values['te_placa_mae_fabricante' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_placa_mae_fabricante' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2943 + Request_Ger_Cols.Values['te_placa_mae_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_placa_mae_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2944 + Request_Ger_Cols.Values['qt_mem_ram' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.qt_mem_ram' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2945 + Request_Ger_Cols.Values['te_mem_ram_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_mem_ram_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2946 + Request_Ger_Cols.Values['te_bios_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_bios_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2947 + Request_Ger_Cols.Values['te_bios_data' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_bios_data' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2948 + Request_Ger_Cols.Values['te_bios_fabricante' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_bios_fabricante' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2949 + Request_Ger_Cols.Values['qt_placa_video_cores' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.qt_placa_video_cores' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2950 + Request_Ger_Cols.Values['te_placa_video_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_placa_video_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2951 + Request_Ger_Cols.Values['qt_placa_video_mem' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.qt_placa_video_mem' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2952 + Request_Ger_Cols.Values['te_placa_video_resolucao'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_placa_video_resolucao',v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2953 + Request_Ger_Cols.Values['te_placa_som_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_placa_som_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2954 + Request_Ger_Cols.Values['te_teclado_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_teclado_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2955 + Request_Ger_Cols.Values['te_mouse_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_mouse_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  2956 + Request_Ger_Cols.Values['te_modem_desc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Hard.te_modem_desc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
3144 2957 if v_Debugs then
3145 2958 For intLoop := 0 to Request_Ger_Cols.Count-1 do
3146 2959 log_DEBUG('Item "'+Request_Ger_Cols.Names[intLoop]+'" de Col_Hard: '+Request_Ger_Cols.ValueFromIndex[intLoop]);
... ... @@ -3165,14 +2978,14 @@ Begin
3165 2978 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3166 2979  
3167 2980 Request_Ger_Cols.Clear;
3168   - Matar(p_path_cacic+'Temp,'col_hard.dat');
  2981 + Matar(g_oCacic.getCacicPath+'Temp,'col_hard.dat');
3169 2982 End;
3170 2983  
3171   - if (FileExists(p_path_cacic + 'Temp\col_patr.dat')) then
  2984 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_patr.dat')) then
3172 2985 Begin
3173   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_patr.dat encontrado.');
  2986 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_patr.dat encontrado.');
3174 2987 v_acao_gercols := '* Preparando envio de informações de Patrimônio.';
3175   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_patr.dat');
  2988 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_patr.dat');
3176 2989  
3177 2990 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3178 2991 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações Patrimoniais', v_tstrCipherOpened);
... ... @@ -3184,16 +2997,16 @@ Begin
3184 2997 if (GetValorDatMemoria('Col_Patr.nada',v_tstrCipherOpened1)='') then
3185 2998 Begin
3186 2999 // Preparação para envio...
3187   - Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3188   - Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3189   - Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3190   - Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3191   - Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3192   - Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3193   - Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3194   - Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3195   - Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3196   - Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  3000 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3001 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3002 + Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3003 + Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3004 + Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3005 + Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3006 + Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3007 + Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3008 + Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3009 + Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
3197 3010  
3198 3011 if v_Debugs then
3199 3012 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -3228,14 +3041,14 @@ Begin
3228 3041 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3229 3042  
3230 3043 Request_Ger_Cols.Clear;
3231   - Matar(p_path_cacic+'Temp,'col_patr.dat');
  3044 + Matar(g_oCacic.getCacicPath+'Temp,'col_patr.dat');
3232 3045 End;
3233 3046  
3234   - if (FileExists(p_path_cacic + 'Temp\col_moni.dat')) then
  3047 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_moni.dat')) then
3235 3048 Begin
3236   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_moni.dat encontrado.');
  3049 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_moni.dat encontrado.');
3237 3050 v_acao_gercols := '* Preparando envio de informações de Sistemas Monitorados.';
3238   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_moni.dat');
  3051 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_moni.dat');
3239 3052  
3240 3053 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3241 3054 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Sistemas Monitorados', v_tstrCipherOpened);
... ... @@ -3247,7 +3060,7 @@ Begin
3247 3060 if (GetValorDatMemoria('Col_Moni.nada',v_tstrCipherOpened1)='') then
3248 3061 Begin
3249 3062 // Preparação para envio...
3250   - Request_Ger_Cols.Values['te_tripa_monitorados'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Moni.UVC',v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  3063 + Request_Ger_Cols.Values['te_tripa_monitorados'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Moni.UVC',v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
3251 3064  
3252 3065 if v_Debugs then
3253 3066 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -3273,14 +3086,14 @@ Begin
3273 3086 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3274 3087  
3275 3088 Request_Ger_Cols.Clear;
3276   - Matar(p_path_cacic+'Temp,'col_moni.dat');
  3089 + Matar(g_oCacic.getCacicPath+'Temp,'col_moni.dat');
3277 3090 End;
3278 3091  
3279   - if (FileExists(p_path_cacic + 'Temp\col_soft.dat')) then
  3092 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_soft.dat')) then
3280 3093 Begin
3281   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_soft.dat encontrado.');
  3094 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_soft.dat encontrado.');
3282 3095 v_acao_gercols := '* Preparando envio de informações de Softwares.';
3283   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_soft.dat');
  3096 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_soft.dat');
3284 3097  
3285 3098 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3286 3099 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Softwares', v_tstrCipherOpened);
... ... @@ -3292,17 +3105,17 @@ Begin
3292 3105 if (GetValorDatMemoria('Col_Soft.nada',v_tstrCipherOpened1)='') then
3293 3106 Begin
3294 3107 // Preparação para envio...
3295   - Request_Ger_Cols.Values['te_versao_bde' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_bde' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3296   - Request_Ger_Cols.Values['te_versao_dao' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_dao' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3297   - Request_Ger_Cols.Values['te_versao_ado' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_ado' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3298   - Request_Ger_Cols.Values['te_versao_odbc' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_odbc' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3299   - Request_Ger_Cols.Values['te_versao_directx' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_directx' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3300   - Request_Ger_Cols.Values['te_versao_acrobat_reader'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_acrobat_reader',v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3301   - Request_Ger_Cols.Values['te_versao_ie' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_ie' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3302   - Request_Ger_Cols.Values['te_versao_mozilla' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_mozilla' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3303   - Request_Ger_Cols.Values['te_versao_jre' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_versao_jre' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3304   - Request_Ger_Cols.Values['te_inventario_softwares' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Soft.te_inventario_softwares' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
3305   - Request_Ger_Cols.Values['te_variaveis_ambiente' ] := StringReplace(EnCrypt(StringReplace(GetValorDatMemoria('Col_Soft.te_variaveis_ambiente',v_tstrCipherOpened1),'\','<BarrInv>',[rfReplaceAll]),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  3108 + Request_Ger_Cols.Values['te_versao_bde' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_bde' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3109 + Request_Ger_Cols.Values['te_versao_dao' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_dao' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3110 + Request_Ger_Cols.Values['te_versao_ado' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_ado' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3111 + Request_Ger_Cols.Values['te_versao_odbc' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_odbc' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3112 + Request_Ger_Cols.Values['te_versao_directx' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_directx' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3113 + Request_Ger_Cols.Values['te_versao_acrobat_reader'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_acrobat_reader',v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3114 + Request_Ger_Cols.Values['te_versao_ie' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_ie' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3115 + Request_Ger_Cols.Values['te_versao_mozilla' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_mozilla' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3116 + Request_Ger_Cols.Values['te_versao_jre' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_versao_jre' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3117 + Request_Ger_Cols.Values['te_inventario_softwares' ] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Soft.te_inventario_softwares' ,v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
  3118 + Request_Ger_Cols.Values['te_variaveis_ambiente' ] := StringReplace(g_oCacic.enCrypt(StringReplace(GetValorDatMemoria('Col_Soft.te_variaveis_ambiente',v_tstrCipherOpened1),'\','<BarrInv>',[rfReplaceAll])),'+','<MAIS>',[rfReplaceAll]);
3306 3119  
3307 3120 if v_Debugs then
3308 3121 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -3328,14 +3141,14 @@ Begin
3328 3141 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3329 3142  
3330 3143 Request_Ger_Cols.Clear;
3331   - Matar(p_path_cacic+'Temp,'col_soft.dat');
  3144 + Matar(g_oCacic.getCacicPath+'Temp,'col_soft.dat');
3332 3145 End;
3333 3146  
3334   - if (FileExists(p_path_cacic + 'Temp\col_undi.dat')) then
  3147 + if (FileExists(g_oCacic.getCacicPath + 'Temp\col_undi.dat')) then
3335 3148 Begin
3336   - log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_undi.dat encontrado.');
  3149 + log_DEBUG('Indicador '+g_oCacic.getCacicPath + 'Temp\col_undi.dat encontrado.');
3337 3150 v_acao_gercols := '* Preparando envio de informações de Unidades de Disco.';
3338   - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_undi.dat');
  3151 + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'Temp\col_undi.dat');
3339 3152  
3340 3153 // Armazeno dados para informações de coletas na data, via menu popup do Systray
3341 3154 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Unidades de Disco', v_tstrCipherOpened);
... ... @@ -3347,7 +3160,7 @@ Begin
3347 3160 if (GetValorDatMemoria('Col_Undi.nada',v_tstrCipherOpened1)='') then
3348 3161 Begin
3349 3162 // Preparação para envio...
3350   - Request_Ger_Cols.Values['UnidadesDiscos'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Undi.UVC',v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  3163 + Request_Ger_Cols.Values['UnidadesDiscos'] := StringReplace(g_oCacic.enCrypt(GetValorDatMemoria('Col_Undi.UVC',v_tstrCipherOpened1)),'+','<MAIS>',[rfReplaceAll]);
3351 3164  
3352 3165 if v_Debugs then
3353 3166 For intLoop := 0 to Request_Ger_Cols.Count-1 do
... ... @@ -3373,7 +3186,7 @@ Begin
3373 3186 SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
3374 3187  
3375 3188 Request_Ger_Cols.Clear;
3376   - Matar(p_path_cacic+'Temp,'col_undi.dat');
  3189 + Matar(g_oCacic.getCacicPath+'Temp,'col_undi.dat');
3377 3190 End;
3378 3191 Request_Ger_Cols.Free;
3379 3192  
... ... @@ -3391,7 +3204,7 @@ Begin
3391 3204 Except
3392 3205 Begin
3393 3206 log_diario('PROBLEMAS EM EXECUTA_GER_COLS! Ação: ' + v_acao_gercols+'.');
3394   - CriaTXT(p_path_cacic,'ger_erro');
  3207 + CriaTXT(g_oCacic.getCacicPath,'ger_erro');
3395 3208 Finalizar(false);
3396 3209 SetValorDatMemoria('Erro_Fatal_Descricao', v_acao_gercols, v_tstrCipherOpened);
3397 3210 End;
... ... @@ -3399,93 +3212,72 @@ Begin
3399 3212  
3400 3213 End;
3401 3214  
3402   -const
3403   - CACIC_APP_NAME = 'ger_cols';
3404   -
  3215 +var v_path_cacic : String;
3405 3216 begin
3406 3217 g_oCacic := TCACIC.Create();
3407 3218  
3408 3219 if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then begin
3409 3220 Try
3410 3221 // Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.DAT
3411   - tstrTripa1 := explode(ExtractFilePath(ParamStr(0)),'\');
3412   - p_path_cacic := '';
  3222 + tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\');
  3223 + v_path_cacic := '';
3413 3224 For intAux := 0 to tstrTripa1.Count -2 do
3414   - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + ';
  3225 + v_path_cacic := v_path_cacic + tstrTripa1[intAux] + ';
3415 3226  
  3227 + g_oCacic.setCacicPath(v_path_cacic);
3416 3228 v_Debugs := false;
3417   - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then
3418   - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
  3229 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
  3230 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
3419 3231 Begin
3420 3232 v_Debugs := true;
3421   - log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
  3233 + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
3422 3234 End;
3423 3235  
3424   - g_oCacic.setCacicPath(p_path_cacic);
3425   -
3426   - For intAux := 1 to ParamCount do
3427   - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then
3428   - Begin
3429   - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux)))));
3430   - log_DEBUG('Parâmetro para cifragem recebido.');
3431   - End;
  3236 + g_oCacic.setCacicPath(g_oCacic.getCacicPath);
3432 3237  
3433   - // Caso tenha sido invocado por um CACIC2.EXE versão antiga, assumo o valor abaixo...
3434   - // Solução provisória até a convergência das versões do Agente Principal e do Gerente de Coletas
3435   - if (trim(v_CipherKey)='') then
3436   - v_CipherKey := 'CacicBrasil';
3437 3238  
3438   - if (trim(v_CipherKey)<>'') then
3439   - Begin
3440   - v_IV := 'abcdefghijklmnop';
3441 3239  
3442   - // De acordo com a versão do OS, determina-se o ShellCommand para chamadas externas.
3443   - p_Shell_Command := 'cmd.exe /c '; //NT/2K/XP
3444   - if(g_oCacic.isWindows9xME()) then
3445   - p_Shell_Command := 'command.com /c ';
  3240 + // De acordo com a versão do OS, determina-se o ShellCommand para chamadas externas.
  3241 + p_Shell_Command := 'cmd.exe /c '; //NT/2K/XP
  3242 + if(g_oCacic.isWindows9xME()) then
  3243 + p_Shell_Command := 'command.com /c ';
3446 3244  
3447   - if not DirectoryExists(p_path_cacic + 'Temp') then
3448   - ForceDirectories(p_path_cacic + 'Temp');
  3245 + if not DirectoryExists(g_oCacic.getCacicPath + 'Temp') then
  3246 + ForceDirectories(g_oCacic.getCacicPath + 'Temp');
3449 3247  
3450   - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave.
3451   - v_DatFileName := p_path_cacic + 'cacic2.dat';
3452   - v_tstrCipherOpened := TStrings.Create;
3453   - v_tstrCipherOpened := CipherOpen(v_DatFileName);
  3248 + v_tstrCipherOpened := TStrings.Create;
  3249 + v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName);
3454 3250  
3455   - // Obtem a string de identificação do SO (g_te_so), para uso nas comunicações com o Gerente WEB.
3456   - g_te_so := g_oCacic.getWindowsStrId();
  3251 + // Não tirar desta posição
  3252 + SetValorDatMemoria('Configs.TE_SO',g_oCacic.getWindowsStrId(), v_tstrCipherOpened);
3457 3253  
3458   - // Não tirar desta posição
3459   - SetValorDatMemoria('Configs.ID_SO',g_te_so, v_tstrCipherOpened);
  3254 + log_DEBUG('Te_So obtido: "' + g_oCacic.getWindowsStrId() +'"');
3460 3255  
3461   - log_DEBUG('Te_So obtido: "' + g_te_so +'"');
3462   -
3463   - v_scripter := 'wscript.exe';
3464   - // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando este estiver em funcionamento
3465   - AssignFile(v_Aguarde,p_path_cacic + 'temp\aguarde_GER.txt'); {Associa o arquivo a uma variável do tipo TextFile}
3466   - {$IOChecks off}
3467   - Reset(v_Aguarde); {Abre o arquivo texto}
3468   - {$IOChecks on}
3469   - if (IOResult <> 0) then // Arquivo não existe, será recriado.
3470   - Rewrite (v_Aguarde);
  3256 + v_scripter := 'wscript.exe';
  3257 + // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando este estiver em funcionamento
  3258 + AssignFile(v_Aguarde,g_oCacic.getCacicPath + 'temp\aguarde_GER.txt'); {Associa o arquivo a uma variável do tipo TextFile}
  3259 + {$IOChecks off}
  3260 + Reset(v_Aguarde); {Abre o arquivo texto}
  3261 + {$IOChecks on}
  3262 + if (IOResult <> 0) then // Arquivo não existe, será recriado.
  3263 + Rewrite (v_Aguarde);
3471 3264  
3472   - Append(v_Aguarde);
3473   - Writeln(v_Aguarde,'Apenas um pseudo-cookie para o Cacic2 esperar o término de Ger_Cols');
3474   - Append(v_Aguarde);
  3265 + Append(v_Aguarde);
  3266 + Writeln(v_Aguarde,'Apenas um pseudo-cookie para o Cacic2 esperar o término de Ger_Cols');
  3267 + Append(v_Aguarde);
3475 3268  
3476   - ChecaCipher;
3477   - ChecaCompress;
  3269 + ChecaCipher;
  3270 + ChecaCompress;
3478 3271  
3479   - Executa_Ger_Cols;
3480   - Finalizar(true);
3481   - End;
3482   - Except
3483   - Begin
3484   - log_diario('PROBLEMAS EM EXECUTA_GER_COLS! Ação: ' + v_acao_gercols+'.');
3485   - CriaTXT(p_path_cacic,'ger_erro');
3486   - Finalizar(false);
3487   - SetValorDatMemoria('Erro_Fatal_Descricao', v_acao_gercols, v_tstrCipherOpened);
3488   - End;
  3272 + Executa_Ger_Cols;
  3273 + Finalizar(true);
  3274 + Except
  3275 + Begin
  3276 + log_diario('PROBLEMAS EM EXECUTA_GER_COLS! Ação: ' + v_acao_gercols+'.');
  3277 + CriaTXT(g_oCacic.getCacicPath,'ger_erro');
  3278 + Finalizar(false);
  3279 + SetValorDatMemoria('Erro_Fatal_Descricao', v_acao_gercols, v_tstrCipherOpened);
  3280 + End;
3489 3281 End;
3490 3282 End;
3491 3283  
... ...
ini_cols/ini_cols.dpr
... ... @@ -25,22 +25,14 @@ uses
25 25 idFTPCommon,
26 26 idFTP,
27 27 PJVersionInfo,
28   - DCPcrypt2,
29   - DCPrijndael,
30   - DCPbase64,
31 28 CACIC_Library in '..\CACIC_Library.pas';
32 29  
33   -var p_path_cacic,
34   - v_te_senha_login_serv_updates,
  30 +var v_te_senha_login_serv_updates,
35 31 v_versao : string;
36 32 v_array_path_cacic : TStrings;
37 33 intAux,
38 34 v_ContaTempo,
39 35 v_Tolerancia : integer;
40   - v_CipherKey,
41   - v_IV,
42   - v_SeparatorKey,
43   - v_DatFileName,
44 36 v_ModulosOpcoes,
45 37 v_Aux : String;
46 38 v_Debugs : Boolean;
... ... @@ -50,10 +42,11 @@ var v_tstrCipherOpened,
50 42 v_tstrModulosOpcoes,
51 43 v_tstrModuloOpcao : TStrings;
52 44  
53   -// Some constants that are dependant on the cipher being used
54   -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
55   -const KeySize = 32; // 32 bytes = 256 bits
56   - BlockSize = 16; // 16 bytes = 128 bits
  45 +var
  46 + g_oCacic : TCACIC;
  47 +
  48 +const
  49 + CACIC_APP_NAME = 'ini_cols';
57 50  
58 51 function VerFmt(const MS, LS: DWORD): string;
59 52 // Format the version number from the given DWORDs containing the info
... ... @@ -98,8 +91,8 @@ var
98 91 strDataArqLocal, strDataAtual : string;
99 92 begin
100 93 try
101   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
102   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
  94 + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  95 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
103 96 {$IOChecks off}
104 97 Reset(HistoricoLog); {Abre o arquivo texto}
105 98 {$IOChecks on}
... ... @@ -111,7 +104,7 @@ begin
111 104 end;
112 105 if (trim(strMsg) <> '') then
113 106 begin
114   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
  107 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log')));
115 108 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
116 109 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
117 110 begin
... ... @@ -151,36 +144,6 @@ begin
151 144 end;
152 145 end;
153 146  
154   -Function Explode(Texto, Separador : String) : TStrings;
155   -var
156   - strItem : String;
157   - ListaAuxUTILS : TStrings;
158   - NumCaracteres,
159   - TamanhoSeparador,
160   - I : Integer;
161   -Begin
162   - ListaAuxUTILS := TStringList.Create;
163   - strItem := '';
164   - NumCaracteres := Length(Texto);
165   - TamanhoSeparador := Length(Separador);
166   - I := 1;
167   - While I <= NumCaracteres Do
168   - Begin
169   - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then
170   - Begin
171   - if (I = NumCaracteres) then strItem := strItem + Texto[I];
172   - ListaAuxUTILS.Add(trim(strItem));
173   - strItem := '';
174   - I := I + (TamanhoSeparador-1);
175   - end
176   - Else
177   - strItem := strItem + Texto[I];
178   -
179   - I := I + 1;
180   - End;
181   - Explode := ListaAuxUTILS;
182   -end;
183   -
184 147 Function GetValorDatMemoria(p_Chave : String) : String;
185 148 begin
186 149 if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
... ... @@ -189,90 +152,6 @@ begin
189 152 Result := '';
190 153 end;
191 154  
192   -// Pad a string with zeros so that it is a multiple of size
193   -function PadWithZeros(const str : string; size : integer) : string;
194   -var
195   - origsize, i : integer;
196   -begin
197   - Result := str;
198   - origsize := Length(Result);
199   - if ((origsize mod size) <> 0) or (origsize = 0) then
200   - begin
201   - SetLength(Result,((origsize div size)+1)*size);
202   - for i := origsize+1 to Length(Result) do
203   - Result[i] := #0;
204   - end;
205   -end;
206   -
207   -// Encrypt a string and return the Base64 encoded result
208   -function EnCrypt(p_Data : String) : String;
209   -var
210   - l_Cipher : TDCP_rijndael;
211   - l_Data, l_Key, l_IV : string;
212   -begin
213   - Try
214   - // Pad Key, IV and Data with zeros as appropriate
215   - l_Key := PadWithZeros(v_CipherKey,KeySize);
216   - l_IV := PadWithZeros(v_IV,BlockSize);
217   - l_Data := PadWithZeros(p_Data,BlockSize);
218   -
219   - // Create the cipher and initialise according to the key length
220   - l_Cipher := TDCP_rijndael.Create(nil);
221   - if Length(v_CipherKey) <= 16 then
222   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
223   - else if Length(v_CipherKey) <= 24 then
224   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
225   - else
226   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
227   -
228   - // Encrypt the data
229   - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));
230   -
231   - // Free the cipher and clear sensitive information
232   - l_Cipher.Free;
233   - FillChar(l_Key[1],Length(l_Key),0);
234   -
235   - // Return the Base64 encoded result
236   - Result := Base64EncodeStr(l_Data);
237   - Except
238   - End;
239   -end;
240   -
241   -function DeCrypt(p_Data : String) : String;
242   -var
243   - l_Cipher : TDCP_rijndael;
244   - l_Data, l_Key, l_IV : string;
245   -begin
246   - Try
247   - // Pad Key and IV with zeros as appropriate
248   - l_Key := PadWithZeros(v_CipherKey,KeySize);
249   - l_IV := PadWithZeros(v_IV,BlockSize);
250   -
251   - // Decode the Base64 encoded string
252   - l_Data := Base64DecodeStr(p_Data);
253   -
254   - // Create the cipher and initialise according to the key length
255   - l_Cipher := TDCP_rijndael.Create(nil);
256   - if Length(v_CipherKey) <= 16 then
257   - l_Cipher.Init(l_Key[1],128,@l_IV[1])
258   - else if Length(v_CipherKey) <= 24 then
259   - l_Cipher.Init(l_Key[1],192,@l_IV[1])
260   - else
261   - l_Cipher.Init(l_Key[1],256,@l_IV[1]);
262   -
263   - // Decrypt the data
264   - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));
265   -
266   - // Free the cipher and clear sensitive information
267   - l_Cipher.Free;
268   - FillChar(l_Key[1],Length(l_Key),0);
269   -
270   - // Return the result
271   - Result := l_Data;
272   - Except
273   - End;
274   -end;
275   -
276 155 Function CipherOpen(p_DatFileName : string) : TStrings;
277 156 var v_DatFile : TextFile;
278 157 v_strCipherOpened,
... ... @@ -296,14 +175,14 @@ begin
296 175 Readln(v_DatFile,v_strCipherClosed);
297 176 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed);
298 177 CloseFile(v_DatFile);
299   - v_strCipherOpened:= DeCrypt(v_strCipherClosed);
  178 + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
300 179 log_DEBUG('Rotina de Abertura do cacic2.dat RESTAURANDO estado da criptografia.');
301 180 end;
302 181  
303 182 if (trim(v_strCipherOpened)<>'') then
304   - Result := explode(v_strCipherOpened,v_SeparatorKey)
  183 + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey)
305 184 else
306   - Result := explode('Configs.ID_SO'+v_SeparatorKey+ oCacic.getWindowsStrId() +v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
  185 + Result := g_oCacic.explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+ oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorkey);
307 186  
308 187  
309 188 if Result.Count mod 2 <> 0 then
... ... @@ -311,7 +190,7 @@ begin
311 190 log_DEBUG('Vetor MemoryDAT com tamanho IMPAR... Ajustando.');
312 191 Result.Add('');
313 192 End;
314   -
  193 +
315 194 oCacic.Free();
316 195 end;
317 196  
... ... @@ -346,120 +225,100 @@ begin
346 225 End;
347 226 end;
348 227  
349   -const
350   - CACIC_APP_NAME = 'ini_cols';
351   -
352   -var
353   - oCacic : TCACIC;
354   -
  228 +var v_path_cacic : String;
355 229 begin
356   - oCacic := TCACIC.Create();
  230 + g_oCacic := TCACIC.Create();
357 231  
358   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  232 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
359 233 if (ParamCount>0) then // A passagem da chave EAS é mandatória...
360 234 Begin
361   - For intAux := 1 to ParamCount do
  235 + //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.dat
  236 + v_array_path_cacic := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\');
  237 + v_path_cacic := '';
  238 + For intAux := 0 to v_array_path_cacic.Count -2 do
  239 + v_path_cacic := v_path_cacic + v_array_path_cacic[intAux] + '\';
  240 +
  241 + g_oCacic.setCacicPath(v_path_cacic);
  242 + v_Debugs := false;
  243 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
362 244 Begin
363   - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then
364   - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux)))));
  245 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
  246 + Begin
  247 + v_Debugs := true;
  248 + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
  249 + End;
365 250 End;
366 251  
367   - if (trim(v_CipherKey)<>'') then
368   - Begin
369   - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.dat
370   - v_array_path_cacic := explode(ExtractFilePath(ParamStr(0)),'\');
371   - p_path_cacic := '';
372   - For intAux := 0 to v_array_path_cacic.Count -2 do
373   - begin
374   - p_path_cacic := p_path_cacic + v_array_path_cacic[intAux] + '\';
375   - end;
376   -
377   - v_Debugs := false;
378   - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then
  252 + // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando a coleta ainda estiver sendo efetuada
  253 + AssignFile(v_Aguarde,g_oCacic.getCacicPath + 'temp\aguarde_INI.txt'); {Associa o arquivo a uma variável do tipo TextFile}
  254 + {$IOChecks off}
  255 + Reset(v_Aguarde); {Abre o arquivo texto}
  256 + {$IOChecks on}
  257 + if (IOResult <> 0) then // Arquivo não existe, será recriado.
  258 + Rewrite (v_Aguarde);
  259 +
  260 + Append(v_Aguarde);
  261 + Writeln(v_Aguarde,'Apenas um pseudo-cookie para o Cacic2 esperar o término de Ini_Cols');
  262 + Append(v_Aguarde);
  263 +
  264 + Matar(g_oCacic.getCacicPath+'temp\','*.dat');
  265 + Try
  266 + // Caso exista o Gerente de Coletas será verificada a versão...
  267 + // Devido a problemas na rotina de FTP na versão 2.0.1.2,
  268 + // que impossibilitava atualização de versões de todos os componentes, exceto INI_COLS
  269 + If (FileExists(g_oCacic.getCacicPath + 'modulos\ger_cols.exe')) Then
379 270 Begin
380   - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
381   - Begin
382   - v_Debugs := true;
383   - log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
384   - End;
385   - End;
386   -
387   - // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando a coleta ainda estiver sendo efetuada
388   - AssignFile(v_Aguarde,p_path_cacic + 'temp\aguarde_INI.txt'); {Associa o arquivo a uma variável do tipo TextFile}
389   - {$IOChecks off}
390   - Reset(v_Aguarde); {Abre o arquivo texto}
391   - {$IOChecks on}
392   - if (IOResult <> 0) then // Arquivo não existe, será recriado.
393   - Rewrite (v_Aguarde);
394   -
395   - Append(v_Aguarde);
396   - Writeln(v_Aguarde,'Apenas um pseudo-cookie para o Cacic2 esperar o término de Ini_Cols');
397   - Append(v_Aguarde);
398   -
399   - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave.
400   - v_IV := 'abcdefghijklmnop';
401   - v_DatFileName := p_path_cacic + 'cacic2.dat';
402   - v_SeparatorKey := '=CacicIsFree=';
403   -
404   - Matar(p_path_cacic+'temp\','*.dat');
405   - Try
406   - // Caso exista o Gerente de Coletas será verificada a versão...
407   - // Devido a problemas na rotina de FTP na versão 2.0.1.2,
408   - // que impossibilitava atualização de versões de todos os componentes, exceto INI_COLS
409   - If (FileExists(p_path_cacic + 'modulos\ger_cols.exe')) Then
410   - Begin
411   - v_versao := trim(GetVersionInfo(p_path_cacic + 'modulos\ger_cols.exe'));
412   - if (v_versao = '0.0.0.0') then // Provavelmente arquivo corrompido ou versão muito antiga
413   - Begin
414   - Matar(p_path_cacic+'modulos\','ger_cols.exe');
415   - Sleep(5000); // Pausa 5 segundos para total exclusão de GER_COLS
416   - CipherOpen(v_DatFileName);
417   - v_te_senha_login_serv_updates := GetValorDatMemoria('Configs.te_senha_login_serv_updates');
418   -
419   - FTP(GetValorDatMemoria('Configs.te_serv_updates'),
420   - GetValorDatMemoria('Configs.nu_porta_serv_updates'),
421   - GetValorDatMemoria('Configs.nm_usuario_login_serv_updates'),
422   - v_te_senha_login_serv_updates,
423   - GetValorDatMemoria('Configs.te_path_serv_updates'),
424   - 'ger_cols.exe',
425   - p_path_cacic + 'modulos');
426   -
427   - // Pausa 5 segundos para total gravação de GER_COLS
428   - Sleep(5000);
429   -
430   - End;
431   - End;
432   -
433   - // Procuro pelo parâmetro p_ModulosOpcoes que deverá ter sido passado pelo Gerente de Coletas
434   - // Contendo a formação: coletor1,wait#coletor2,nowait#coletorN,nowait#
435   - // Observações:
436   - // 1) Os valores "wait/nowait" determinam se o Inicializador de Coletas estará sujeito à tolerância de tempo para as coletas.
437   - // 2) No caso de Coletor de Patrimônio, este depende de digitação e deverá trazer a opção "wait";
438   - // 3) Ainda no caso de Coletor de Patrimônio, quando este for invocado através do menu, o Gerente de Coletas enviará a opção "user", ficando o parâmetro p_ModulosOpcoes = "col_patr,wait,user"
439   - For intAux := 1 to ParamCount do
  271 + v_versao := trim(GetVersionInfo(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'));
  272 + if (v_versao = '0.0.0.0') then // Provavelmente arquivo corrompido ou versão muito antiga
440 273 Begin
441   - if LowerCase(Copy(ParamStr(intAux),1,17)) = '/p_modulosopcoes=' then
442   - v_ModulosOpcoes := Trim(Copy(ParamStr(intAux),18,Length((ParamStr(intAux)))));
443   - End;
444   -
445   - log_DEBUG('Parâmetro p_ModulosOpcoes recebido: '+v_ModulosOpcoes);
446   - v_tstrModulosOpcoes := explode(v_ModulosOpcoes,'#');
447   -
448   - // Tempo de tolerância para as coletas
449   - v_Tolerancia := 5; // (minutos)
450   -
451   - For intAux := 0 to v_tstrModulosOpcoes.Count -1 do
452   - Begin
453   - v_tstrModuloOpcao := explode(v_tstrModulosOpcoes[intAux],',');
454   - v_Aux := v_tstrModuloOpcao[0]+'.exe /p_CipherKey='+v_CipherKey+ ' /p_Option='+v_tstrModuloOpcao[2];
455   - log_DEBUG('Chamando "' + v_tstrModuloOpcao[0]+'.exe /p_CipherKey=*****" /p_Option='+v_tstrModuloOpcao[2]);
456   -
457   - oCacic.createSampleProcess( p_path_cacic + '\modulos\' + v_aux, CACIC_PROCESS_WAIT );
  274 + Matar(g_oCacic.getCacicPath+'modulos\','ger_cols.exe');
  275 + Sleep(5000); // Pausa 5 segundos para total exclusão de GER_COLS
  276 + CipherOpen(g_oCacic.getDatFileName);
  277 + v_te_senha_login_serv_updates := GetValorDatMemoria('Configs.te_senha_login_serv_updates');
  278 +
  279 + FTP(GetValorDatMemoria('Configs.te_serv_updates'),
  280 + GetValorDatMemoria('Configs.nu_porta_serv_updates'),
  281 + GetValorDatMemoria('Configs.nm_usuario_login_serv_updates'),
  282 + v_te_senha_login_serv_updates,
  283 + GetValorDatMemoria('Configs.te_path_serv_updates'),
  284 + 'ger_cols.exe',
  285 + g_oCacic.getCacicPath + 'modulos');
  286 +
  287 + // Pausa 5 segundos para total gravação de GER_COLS
  288 + Sleep(5000);
458 289  
459 290 End;
460   - except
461   - end;
462   - End;
  291 + End;
  292 +
  293 + // Procuro pelo parâmetro p_ModulosOpcoes que deverá ter sido passado pelo Gerente de Coletas
  294 + // Contendo a formação: coletor1,wait#coletor2,nowait#coletorN,nowait#
  295 + // Observações:
  296 + // 1) Os valores "wait/nowait" determinam se o Inicializador de Coletas estará sujeito à tolerância de tempo para as coletas.
  297 + // 2) No caso de Coletor de Patrimônio, este depende de digitação e deverá trazer a opção "wait";
  298 + // 3) Ainda no caso de Coletor de Patrimônio, quando este for invocado através do menu, o Gerente de Coletas enviará a opção "user", ficando o parâmetro p_ModulosOpcoes = "col_patr,wait,user"
  299 + For intAux := 1 to ParamCount do
  300 + Begin
  301 + if LowerCase(Copy(ParamStr(intAux),1,17)) = '/p_modulosopcoes=' then
  302 + v_ModulosOpcoes := Trim(Copy(ParamStr(intAux),18,Length((ParamStr(intAux)))));
  303 + End;
  304 +
  305 + log_DEBUG('Parâmetro p_ModulosOpcoes recebido: '+v_ModulosOpcoes);
  306 + v_tstrModulosOpcoes := g_oCacic.explode(v_ModulosOpcoes,'#');
  307 +
  308 + // Tempo de tolerância para as coletas
  309 + v_Tolerancia := 5; // (minutos)
  310 +
  311 + For intAux := 0 to v_tstrModulosOpcoes.Count -1 do
  312 + Begin
  313 + v_tstrModuloOpcao := g_oCacic.explode(v_tstrModulosOpcoes[intAux],',');
  314 + v_Aux := v_tstrModuloOpcao[0]+'.exe /p_Option='+v_tstrModuloOpcao[2];
  315 + log_DEBUG('Chamando "' + v_tstrModuloOpcao[0]+'.exe " /p_Option='+v_tstrModuloOpcao[2]);
  316 +
  317 + g_oCacic.createSampleProcess( g_oCacic.getCacicPath + '\modulos\' + v_aux, CACIC_PROCESS_WAIT );
  318 +
  319 + End;
  320 + except
  321 + end;
463 322 End;
464   - oCacic.Free();
  323 + g_oCacic.Free();
465 324 end.
... ...