From eb8d42dd711267e6e582e54d3a31c0850758cfe6 Mon Sep 17 00:00:00 2001 From: anderson.peterle@previdencia.gov.br Date: Thu, 10 Mar 2011 19:26:31 +0000 Subject: [PATCH] Exclusão para posterior reposição com versão 2.6-Beta-2 --- col_comp/col_comp.cfg | 38 -------------------------------------- col_comp/col_comp.dof | 136 ---------------------------------------------------------------------------------------------------------------------------------------- col_comp/col_comp.dpr | 390 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ col_comp/col_comp.res | Bin 16296 -> 0 bytes col_comp/col_comp_icon.ico | Bin 15134 -> 0 bytes col_comp/main_comp.ddp | Bin 51 -> 0 bytes col_comp/main_comp.dfm | 18 ------------------ col_comp/main_comp.pas | 424 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 8 files changed, 0 insertions(+), 1006 deletions(-) delete mode 100755 col_comp/col_comp.cfg delete mode 100755 col_comp/col_comp.dof delete mode 100755 col_comp/col_comp.dpr delete mode 100755 col_comp/col_comp.res delete mode 100755 col_comp/col_comp_icon.ico delete mode 100755 col_comp/main_comp.ddp delete mode 100755 col_comp/main_comp.dfm delete mode 100755 col_comp/main_comp.pas diff --git a/col_comp/col_comp.cfg b/col_comp/col_comp.cfg deleted file mode 100755 index bce8f6c..0000000 --- a/col_comp/col_comp.cfg +++ /dev/null @@ -1,38 +0,0 @@ --$A8 --$B- --$C+ --$D+ --$E- --$F- --$G+ --$H+ --$I+ --$J- --$K- --$L+ --$M- --$N+ --$O+ --$P+ --$Q- --$R- --$S- --$T- --$U- --$V+ --$W- --$X+ --$YD --$Z1 --cg --AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; --H+ --W+ --M --$M16384,1048576 --K$00400000 --LE"c:\arquivos de programas\borland\delphi7\Projects\Bpl" --LN"c:\arquivos de programas\borland\delphi7\Projects\Bpl" --w-UNSAFE_TYPE --w-UNSAFE_CODE --w-UNSAFE_CAST diff --git a/col_comp/col_comp.dof b/col_comp/col_comp.dof deleted file mode 100755 index 2acef56..0000000 --- a/col_comp/col_comp.dof +++ /dev/null @@ -1,136 +0,0 @@ -[FileVersion] -Version=7.0 -[Compiler] -A=8 -B=0 -C=1 -D=1 -E=0 -F=0 -G=1 -H=1 -I=1 -J=0 -K=0 -L=1 -M=0 -N=1 -O=1 -P=1 -Q=0 -R=0 -S=0 -T=0 -U=0 -V=1 -W=0 -X=1 -Y=1 -Z=1 -ShowHints=1 -ShowWarnings=1 -UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -NamespacePrefix= -SymbolDeprecated=1 -SymbolLibrary=1 -SymbolPlatform=1 -UnitLibrary=1 -UnitPlatform=1 -UnitDeprecated=1 -HResultCompat=1 -HidingMember=1 -HiddenVirtual=1 -Garbage=1 -BoundsError=1 -ZeroNilCompat=1 -StringConstTruncated=1 -ForLoopVarVarPar=1 -TypedConstVarPar=1 -AsgToTypedConst=1 -CaseLabelRange=1 -ForVariable=1 -ConstructingAbstract=1 -ComparisonFalse=1 -ComparisonTrue=1 -ComparingSignedUnsigned=1 -CombiningSignedUnsigned=1 -UnsupportedConstruct=1 -FileOpen=1 -FileOpenUnitSrc=1 -BadGlobalSymbol=1 -DuplicateConstructorDestructor=1 -InvalidDirective=1 -PackageNoLink=1 -PackageThreadVar=1 -ImplicitImport=1 -HPPEMITIgnored=1 -NoRetVal=1 -UseBeforeDef=1 -ForLoopVarUndef=1 -UnitNameMismatch=1 -NoCFGFileFound=1 -MessageDirective=1 -ImplicitVariants=1 -UnicodeToLocale=1 -LocaleToUnicode=1 -ImagebaseMultiple=1 -SuspiciousTypecast=1 -PrivatePropAccessor=1 -UnsafeType=0 -UnsafeCode=0 -UnsafeCast=0 -[Linker] -MapFile=0 -OutputObjs=0 -ConsoleApp=1 -DebugInfo=0 -RemoteSymbols=0 -MinStackSize=16384 -MaxStackSize=1048576 -ImageBase=4194304 -ExeDescription= -[Directories] -OutputDir= -UnitOutputDir= -PackageDLLOutputDir= -PackageDCPOutputDir= -SearchPath= -Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOffice2k;MSI_D7_Rtl -Conditionals= -DebugSourceDirs= -UsePackages=0 -[Parameters] -RunParams= -HostApplication= -Launcher= -UseLauncher=0 -DebugCWD= -[Language] -ActiveLang= -ProjectLang= -RootDir=C:\Arquivos de programas\Borland\Delphi7\Bin\ -[Version Info] -IncludeVerInfo=1 -AutoIncBuild=0 -MajorVer=2 -MinorVer=5 -Release=0 -Build=773 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=2070 -CodePage=1252 -[Version Info Keys] -CompanyName=Dataprev - Emp. de TI da Prev.Social - URES -FileDescription=Coletor de Informações de Compartilhamento do Sistema CACIC -FileVersion=2.5.0.773 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName=Col_COMP -ProductVersion=2.6 -Comments=Baseado na licença GPL (General Public License) diff --git a/col_comp/col_comp.dpr b/col_comp/col_comp.dpr deleted file mode 100755 index 12014f7..0000000 --- a/col_comp/col_comp.dpr +++ /dev/null @@ -1,390 +0,0 @@ -(** ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil - -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais - -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão. - -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes. - -Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -*) - -program col_comp; -{$R *.res} - -uses - Windows, - SysUtils, - Classes, - Registry, - CACIC_Library in '..\CACIC_Library.pas'; - -var - v_strCipherClosed : String; - -var - v_tstrCipherOpened, - v_tstrCipherOpened1 : TStrings; - -var - g_oCacic : TCACIC; - -procedure log_diario(strMsg : String); -var - HistoricoLog : TextFile; - strDataArqLocal, strDataAtual : string; -begin - try - FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} - {$IOChecks off} - Reset(HistoricoLog); {Abre o arquivo texto} - {$IOChecks on} - if (IOResult <> 0) then // Arquivo não existe, será recriado. - begin - Rewrite (HistoricoLog); - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log'))); - DateTimeToString(strDataAtual , 'yyyymmdd', Date); - if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... - begin - Rewrite (HistoricoLog); //Cria/Recria o arquivo - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now)+ '[Coletor COMP] '+strMsg); {Grava a string Texto no arquivo texto} - CloseFile(HistoricoLog); {Fecha o arquivo texto} - - except - log_diario('Erro na gravação do log!'); - end; -end; - -Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; -var v_strCipherOpenImploded : string; - v_DatFile : TextFile; -begin - try - FileSetAttr (p_DatFileName,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(v_DatFile,p_DatFileName); {Associa o arquivo a uma variável do tipo TextFile} - - // Criação do arquivo .DAT - Rewrite (v_DatFile); - Append(v_DatFile); - - v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey); - v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded); - Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto} - CloseFile(v_DatFile); - except - end; -end; - -Function CipherOpen(p_DatFileName : string) : TStrings; -var v_DatFile : TextFile; - v_strCipherOpened, - v_strCipherClosed : string; -begin - v_strCipherOpened := ''; - if FileExists(p_DatFileName) then - begin - AssignFile(v_DatFile,p_DatFileName); - {$IOChecks off} - Reset(v_DatFile); - {$IOChecks on} - if (IOResult <> 0) then // Arquivo não existe, será recriado. - begin - Rewrite (v_DatFile); - Append(v_DatFile); - end; - - Readln(v_DatFile,v_strCipherClosed); - while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); - CloseFile(v_DatFile); - v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed); - end; - if (trim(v_strCipherOpened)<>'') then - Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey) - else - Result := g_oCacic.explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+g_oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey); - - - if Result.Count mod 2 <> 0 then - Result.Add(''); -end; - -Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings); -begin - // Exemplo: p_Chave => Configs.nu_ip_servidor : p_Valor => 10.71.0.120 - if (p_tstrCipherOpened.IndexOf(p_Chave)<>-1) then - p_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1] := p_Valor - else - Begin - p_tstrCipherOpened.Add(p_Chave); - p_tstrCipherOpened.Add(p_Valor); - End; - -end; - -Function GetValorDatMemoria(p_Chave : String) : String; -begin - if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then - Result := v_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1] - else - Result := ''; -end; - -function GetRootKey(strRootKey: String): HKEY; -begin - /// Encontrar uma maneira mais elegante de fazer esses testes. - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA; -end; - -Function RemoveCaracteresEspeciais(Texto : String) : String; -var I : Integer; - strAux : String; -Begin - For I := 0 To Length(Texto) Do - if ord(Texto[I]) in [32..126] Then - strAux := strAux + Texto[I] - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais - Result := strAux; -end; - -function GetValorChaveRegEdit(Chave: String): Variant; -var RegEditGet: TRegistry; - RegDataType: TRegDataType; - strRootKey, strKey, strValue, s: String; - ListaAuxGet : TStrings; - DataSize, Len, I : Integer; -begin - try - Result := ''; - ListaAuxGet := g_oCacic.explode(Chave, '\'); - - strRootKey := ListaAuxGet[0]; - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; - strValue := ListaAuxGet[ListaAuxGet.Count - 1]; - if (strValue = '(Padrão)') then strValue := ''; //Para os casos de se querer buscar o valor default (Padrão) - RegEditGet := TRegistry.Create; - - RegEditGet.Access := KEY_READ; - RegEditGet.Rootkey := GetRootKey(strRootKey); - if RegEditGet.OpenKeyReadOnly(strKey) then //teste - Begin - RegDataType := RegEditGet.GetDataType(strValue); - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue) - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue) - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown) - then - begin - DataSize := RegEditGet.GetDataSize(strValue); - if DataSize = -1 then exit; - SetLength(s, DataSize); - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize); - if Len <> DataSize then exit; - Result := RemoveCaracteresEspeciais(s); - end - end; - finally - RegEditGet.CloseKey; - RegEditGet.Free; - ListaAuxGet.Free; - - end; -end; - -procedure Executa_Col_comp; - - function RetornaValorShareNT(ValorReg : String; LimiteEsq : String; LimiteDir : String) : String; - var intAux, intAux2 : Integer; - Begin - intAux := Pos(LimiteEsq, ValorReg) + Length(LimiteEsq); - if (LimiteDir = 'Fim') Then intAux2 := Length(ValorReg) - 1 - Else intAux2 := Pos(LimiteDir, ValorReg) - intAux - 1; - result := Trim(Copy(ValorReg, intAux, intAux2)); - end; - -var Reg_RCC : TRegistry; - ChaveRegistro, ValorChaveRegistro, nm_compartilhamento, nm_dir_compart, - in_senha_escrita, in_senha_leitura, te_comentario, strTripaDados, strAux, - cs_tipo_permissao, cs_tipo_compart : String; - I, intAux: Integer; - Lista_RCC : TStringList; -Begin - Try - Begin - SetValorDatMemoria('Col_Comp.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1); - nm_compartilhamento := ''; - nm_dir_compart := ''; - cs_tipo_compart := ' '; - cs_tipo_permissao := ' '; - in_senha_leitura := ''; - in_senha_escrita := ''; - log_diario('Coletando informações de Compartilhamentos.'); - Reg_RCC := TRegistry.Create; - Reg_RCC.LazyWrite := False; - Lista_RCC := TStringList.Create; - Reg_RCC.Rootkey := HKEY_LOCAL_MACHINE; - strTripaDados := ''; - - if Win32Platform = VER_PLATFORM_WIN32_NT then - Begin // 2k, xp, nt. - ChaveRegistro := '\System\ControlSet001\Services\lanmanserver\Shares\'; - Reg_RCC.OpenKeyReadOnly(ChaveRegistro); - Reg_RCC.GetValueNames(Lista_RCC); - Reg_RCC.CloseKey; - For I := 0 To Lista_RCC.Count - 1 Do - Begin - nm_compartilhamento := Lista_RCC.Strings[i]; - strAux := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE' + ChaveRegistro + nm_compartilhamento); - nm_dir_compart := RetornaValorShareNT(strAux, 'Path=', 'Permissions='); - te_comentario := RetornaValorShareNT(strAux, 'Remark=', 'Type='); - cs_tipo_compart := RetornaValorShareNT(strAux, 'Type=', 'Fim'); - if (cs_tipo_compart = '0') Then cs_tipo_compart := 'D' Else cs_tipo_compart := 'I'; - if (strTripaDados <> '') then - strTripaDados := strTripaDados + ''; // Delimitador de REGISTRO - - strTripaDados := strTripaDados + nm_compartilhamento + '' + - nm_dir_compart + '' + - cs_tipo_compart + '' + - te_comentario; - end; - end - Else - Begin - ChaveRegistro := '\Software\Microsoft\Windows\CurrentVersion\Network\LanMan\'; - Reg_RCC.OpenKeyReadOnly(ChaveRegistro); - Reg_RCC.GetKeyNames(Lista_RCC); - Reg_RCC.CloseKey; - For I := 0 To Lista_RCC.Count - 1 Do - Begin - nm_compartilhamento := Lista_RCC.Strings[i]; - Reg_RCC.OpenKey(ChaveRegistro + nm_compartilhamento, True); - nm_dir_compart := Reg_RCC.ReadString('Path'); - te_comentario := Reg_RCC.ReadString('Remark'); - if (Reg_RCC.GetDataSize('Parm1enc') = 0) Then in_senha_escrita := '0' Else in_senha_escrita := '1'; - if (Reg_RCC.GetDataSize('Parm2enc') = 0) Then in_senha_leitura := '0' Else in_senha_leitura := '1'; - if (Reg_RCC.ReadInteger('Type') = 0) Then cs_tipo_compart := 'D' Else cs_tipo_compart := 'I'; - intAux := Reg_RCC.ReadInteger('Flags'); - Case intAux of //http://www.la2600.org/talks/chronology/enigma/19971107.html - 401 : cs_tipo_permissao := 'S'; // Somente Leitura. - 258 : cs_tipo_permissao := 'C'; // Completo. - 259 : cs_tipo_permissao := 'D'; // Depende de senha. - end; - Reg_RCC.CloseKey; - { - strXML := strXML + '' + - '' + nm_compartilhamento + '' + - '' + nm_dir_compart + '' + - '' + cs_tipo_compart + '' + - '' + cs_tipo_permissao + '' + - '' + in_senha_leitura + '' + - '' + in_senha_escrita + '' + - '' + te_comentario + '' + - ''; - } - if (strTripaDados <> '') then - strTripaDados := strTripaDados + ''; // Delimitador de REGISTRO - - strTripaDados := strTripaDados + nm_compartilhamento + '' + - nm_dir_compart + '' + - cs_tipo_compart + '' + - te_comentario + '' + - in_senha_leitura + '' + - in_senha_escrita + '' + - cs_tipo_permissao; - end; - end; - - Reg_RCC.Free; - Lista_RCC.Free; - - - // Obtenho do registro o valor que foi previamente armazenado - ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.Compartilhamentos')); - - SetValorDatMemoria('Col_Comp.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1); - - // Se essas informações forem diferentes significa que houve alguma alteração - // na configuração. Nesse caso, gravo as informações no BD Central e, se não houver - // problemas durante esse procedimento, atualizo as informações no registro. - If ((GetValorDatMemoria('Configs.IN_COLETA_FORCADA_COMP')='S') or (strTripaDados <> ValorChaveRegistro)) and - (strTripaDados <> '') Then - Begin - SetValorDatMemoria('Col_Comp.UVC', strTripaDados, v_tstrCipherOpened1); - CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); - End - else - SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1); - - CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); - End; - Except - Begin - SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1); - SetValorDatMemoria('Col_Comp.Fim', '99999999', v_tstrCipherOpened1); - CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); - End; - End; -end; - -var tstrTripa1 : TStrings; - intAux : integer; - strAux : String; - -const - CACIC_APP_NAME = 'col_comp'; - -begin - g_oCacic := TCACIC.Create(); - - g_oCacic.setBoolCipher(true); - - if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then - if (ParamCount>0) then - Begin - strAux := ''; - For intAux := 1 to ParamCount do - Begin - if LowerCase(Copy(ParamStr(intAux),1,11)) = '/cacicpath=' then - begin - strAux := Trim(Copy(ParamStr(intAux),12,Length((ParamStr(intAux))))); - end; - end; - - if (strAux <> '') then - Begin - g_oCacic.setCacicPath(strAux); - - v_tstrCipherOpened := TStrings.Create; - v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + g_oCacic.getDatFileName); - - v_tstrCipherOpened1 := TStrings.Create; - v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_comp.dat'); - - Try - Executa_Col_comp; - Except - SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1); - CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); - End; - Halt(0); - End; - End; - g_oCacic.Free(); -end. diff --git a/col_comp/col_comp.res b/col_comp/col_comp.res deleted file mode 100755 index 89f9126..0000000 Binary files a/col_comp/col_comp.res and /dev/null differ diff --git a/col_comp/col_comp_icon.ico b/col_comp/col_comp_icon.ico deleted file mode 100755 index e2b1a87..0000000 Binary files a/col_comp/col_comp_icon.ico and /dev/null differ diff --git a/col_comp/main_comp.ddp b/col_comp/main_comp.ddp deleted file mode 100755 index 4370276..0000000 Binary files a/col_comp/main_comp.ddp and /dev/null differ diff --git a/col_comp/main_comp.dfm b/col_comp/main_comp.dfm deleted file mode 100755 index 16df0fb..0000000 --- a/col_comp/main_comp.dfm +++ /dev/null @@ -1,18 +0,0 @@ -object frmcol_comp: Tfrmcol_comp - Left = 912 - Top = 715 - Width = 112 - Height = 27 - Caption = 'CACIC - Coletor Compartilhamentos' - Color = clBtnFace - TransparentColor = True - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - OldCreateOrder = False - OnCreate = FormCreate - PixelsPerInch = 96 - TextHeight = 13 -end diff --git a/col_comp/main_comp.pas b/col_comp/main_comp.pas deleted file mode 100755 index 42324dc..0000000 --- a/col_comp/main_comp.pas +++ /dev/null @@ -1,424 +0,0 @@ -(** ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil - -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais - -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão. - -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes. - -Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -*) - -unit main_comp; - -interface - -uses Windows, Forms, IniFiles, SysUtils, Classes, Registry; -var p_path_cacic, p_path_cacic_ini : string; -type - Tfrmcol_comp = class(TForm) - procedure Executa_Col_comp; - procedure Log_Historico(strMsg : String); - Function Crip(PNome: String): String; - Function DesCrip(PNome: String): String; - function SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String; -// function GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String; - function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; - function GetValorChaveRegEdit(Chave: String): Variant; - function GetRootKey(strRootKey: String): HKEY; - Function Explode(Texto, Separador : String) : TStrings; - Function RemoveCaracteresEspeciais(Texto : String) : String; - procedure FormCreate(Sender: TObject); - private - { Private declarations } - public - { Public declarations } - end; - -var - frmcol_comp: Tfrmcol_comp; - -implementation - -{$R *.dfm} - -//Para gravar no Arquivo INI... -function Tfrmcol_comp.SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String; -var Reg_Ini : TIniFile; -begin - FileSetAttr (p_Path,0); - Reg_Ini := TIniFile.Create(p_Path); -// Reg_Ini.WriteString(frmcol_comp.Crip(p_Secao), frmcol_comp.Crip(p_Chave), frmcol_comp.Crip(p_Valor)); - Reg_Ini.WriteString(p_Secao, p_Chave, p_Valor); - Reg_Ini.Free; -end; - -//Para buscar do Arquivo INI... -//function Tfrmcol_comp.GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String; -//var Reg_Ini: TIniFile; -//begin -// FileSetAttr (p_Path,0); -// Reg_Ini := TIniFile.Create(p_Path); -//// Result := frmcol_comp.DesCrip(Reg_Ini.ReadString(frmcol_comp.Crip(p_Secao), frmcol_comp.Crip(p_Chave), '')); -// Result := Reg_Ini.ReadString(p_Secao, p_Chave, ''); -// Reg_Ini.Free; -//end; -//Para buscar do Arquivo INI... -// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções -function Tfrmcol_comp.GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; -var - FileText : TStringList; - i, j, v_Size_Section, v_Size_Key : integer; - v_SectionName, v_KeyName : string; - begin - Result := ''; - v_SectionName := '[' + p_SectionName + ']'; - v_Size_Section := strLen(PChar(v_SectionName)); - v_KeyName := p_KeyName + '='; - v_Size_Key := strLen(PChar(v_KeyName)); - FileText := TStringList.Create; - try - FileText.LoadFromFile(p_IniFileName); - For i := 0 To FileText.Count - 1 Do - Begin - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then - Begin - For j := i to FileText.Count - 1 Do - Begin - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then - Begin - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key)); - Break; - End; - End; - End; - if (Result <> '') then break; - End; - finally - FileText.Free; - end; - end; - - -Function Tfrmcol_comp.Explode(Texto, Separador : String) : TStrings; -var - strItem : String; - ListaAuxUTILS : TStrings; - NumCaracteres, I : Integer; -Begin - ListaAuxUTILS := TStringList.Create; - strItem := ''; - NumCaracteres := Length(Texto); - For I := 0 To NumCaracteres Do - If (Texto[I] = Separador) or (I = NumCaracteres) Then - Begin - If (I = NumCaracteres) then strItem := strItem + Texto[I]; - ListaAuxUTILS.Add(Trim(strItem)); - strItem := ''; - end - Else strItem := strItem + Texto[I]; - Explode := ListaAuxUTILS; -//Não estava sendo liberado -// ListaAuxUTILS.Free; -//Ao ativar esta liberação tomei uma baita surra!!!! 11/05/2004 - 20:30h - Uma noite muito escura! :) Anderson Peterle -end; - -function Tfrmcol_comp.GetRootKey(strRootKey: String): HKEY; -begin - /// Encontrar uma maneira mais elegante de fazer esses testes. - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA; -end; - -Function Tfrmcol_comp.RemoveCaracteresEspeciais(Texto : String) : String; -var I : Integer; - strAux : String; -Begin - For I := 0 To Length(Texto) Do - if ord(Texto[I]) in [32..126] Then - strAux := strAux + Texto[I] - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais - Result := strAux; -end; - -function Tfrmcol_comp.GetValorChaveRegEdit(Chave: String): Variant; -var RegEditGet: TRegistry; - RegDataType: TRegDataType; - strRootKey, strKey, strValue, s: String; - ListaAuxGet : TStrings; - DataSize, Len, I : Integer; -begin - try - Result := ''; - ListaAuxGet := frmcol_comp.Explode(Chave, '\'); - - strRootKey := ListaAuxGet[0]; - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; - strValue := ListaAuxGet[ListaAuxGet.Count - 1]; - if (strValue = '(Padrão)') then strValue := ''; //Para os casos de se querer buscar o valor default (Padrão) - RegEditGet := TRegistry.Create; - - RegEditGet.Access := KEY_READ; - RegEditGet.Rootkey := GetRootKey(strRootKey); - if RegEditGet.OpenKeyReadOnly(strKey) then //teste - Begin - RegDataType := RegEditGet.GetDataType(strValue); - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue) - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue) - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown) - then - begin - DataSize := RegEditGet.GetDataSize(strValue); - if DataSize = -1 then exit; - SetLength(s, DataSize); - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize); - if Len <> DataSize then exit; - Result := frmcol_comp.RemoveCaracteresEspeciais(s); - end - end; - finally - RegEditGet.CloseKey; - RegEditGet.Free; - ListaAuxGet.Free; - - end; -end; - - -// Simples rotinas de Criptografação e Descriptografação -// Baixadas de http://www.costaweb.com.br/forum/delphi/474.shtml -Function Tfrmcol_comp.Crip(PNome: String): String; -Var - TamI, TamF: Integer; - SenA, SenM, SenD: String; -Begin - SenA := Trim(PNome); - TamF := Length(SenA); - if (TamF > 1) then - begin - SenM := ''; - SenD := ''; - For TamI := TamF Downto 1 do - Begin - SenM := SenM + Copy(SenA,TamI,1); - End; - SenD := Chr(TamF+95)+Copy(SenM,1,1)+Copy(SenA,1,1)+Copy(SenM,2,TamF-2)+Chr(75+TamF); - end - else SenD := SenA; - Result := SenD; -End; - -Function Tfrmcol_comp.DesCrip(PNome: String): String; -Var - TamI, TamF: Integer; - SenA, SenM, SenD: String; -Begin - SenA := Trim(PNome); - TamF := Length(SenA) - 2; - if (TamF > 1) then - begin - SenM := ''; - SenD := ''; - SenA := Copy(SenA,2,TamF); - SenM := Copy(SenA,1,1)+Copy(SenA,3,TamF)+Copy(SenA,2,1); - For TamI := TamF Downto 1 do - Begin - SenD := SenD + Copy(SenM,TamI,1); - End; - end - else SenD := SenA; - Result := SenD; -End; - -procedure Tfrmcol_comp.Log_Historico(strMsg : String); -var - HistoricoLog : TextFile; - strDataArqLocal, strDataAtual : string; -begin - try - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} - {$IOChecks off} - Reset(HistoricoLog); {Abre o arquivo texto} - {$IOChecks on} - if (IOResult <> 0) then // Arquivo não existe, será recriado. - begin - Rewrite (HistoricoLog); - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); - DateTimeToString(strDataAtual , 'yyyymmdd', Date); - if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... - begin - Rewrite (HistoricoLog); //Cria/Recria o arquivo - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + strMsg); {Grava a string Texto no arquivo texto} - CloseFile(HistoricoLog); {Fecha o arquivo texto} -// FileSetAttr (ExtractFilePath(Application.Exename) + '\cacic2.log',6); // Muda o atributo para arquivo de SISTEMA e OCULTO - - except - Log_Historico('Erro na gravação do log!'); - end; -end; - - - -procedure Tfrmcol_comp.Executa_Col_comp; -function RetornaValorShareNT(ValorReg : String; LimiteEsq : String; LimiteDir : String) : String; -var intAux, intAux2 : Integer; -Begin - intAux := Pos(LimiteEsq, ValorReg) + Length(LimiteEsq); - if (LimiteDir = 'Fim') Then intAux2 := Length(ValorReg) - 1 - Else intAux2 := Pos(LimiteDir, ValorReg) - intAux - 1; - result := Trim(Copy(ValorReg, intAux, intAux2)); -end; -var Reg_RCC : TRegistry; - ChaveRegistro, ValorChaveRegistro, nm_compartilhamento, nm_dir_compart, - in_senha_escrita, in_senha_leitura, te_comentario, strXML, strAux, - cs_tipo_permissao, cs_tipo_compart : String; - I, intAux: Integer; - Lista_RCC : TStringList; -Begin - Try - nm_compartilhamento := ''; - nm_dir_compart := ''; - cs_tipo_compart := ' '; - cs_tipo_permissao := ' '; - in_senha_leitura := ''; - in_senha_escrita := ''; - Log_Historico('* Coletando informações de Compartilhamentos.'); - Reg_RCC := TRegistry.Create; - Reg_RCC.LazyWrite := False; - Lista_RCC := TStringList.Create; - Reg_RCC.Rootkey := HKEY_LOCAL_MACHINE; - { - strXML := '' + - '' + - '' + GetValorChaveRegIni('TcpIp' ,'TE_NODE_ADDRESS' ,p_path_cacic_ini) + '' + - '' + GetValorChaveRegIni('TcpIp' ,'TE_NOME_COMPUTADOR',p_path_cacic_ini) + '' + - '' + GetValorChaveRegIni('TcpIp' ,'TE_WORKGROUP' ,p_path_cacic_ini) + '' + - '' + GetValorChaveRegIni('Configs','ID_SO' ,p_path_cacic_ini) + ''; - } - - strXML := ''; - - if Win32Platform = VER_PLATFORM_WIN32_NT then - Begin // 2k, xp, nt. - ChaveRegistro := '\System\ControlSet001\Services\lanmanserver\Shares\'; - Reg_RCC.OpenKeyReadOnly(ChaveRegistro); - Reg_RCC.GetValueNames(Lista_RCC); - Reg_RCC.CloseKey; - For I := 0 To Lista_RCC.Count - 1 Do - Begin - nm_compartilhamento := Lista_RCC.Strings[i]; - strAux := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE' + ChaveRegistro + nm_compartilhamento); - nm_dir_compart := RetornaValorShareNT(strAux, 'Path=', 'Permissions='); - te_comentario := RetornaValorShareNT(strAux, 'Remark=', 'Type='); - cs_tipo_compart := RetornaValorShareNT(strAux, 'Type=', 'Fim'); - if (cs_tipo_compart = '0') Then cs_tipo_compart := 'D' Else cs_tipo_compart := 'I'; - strXML := strXML + '' + - '' + nm_compartilhamento + '' + - '' + nm_dir_compart + '' + - '' + cs_tipo_compart + '' + - '' + te_comentario + '' + - ''; - end; - end - Else - Begin - ChaveRegistro := '\Software\Microsoft\Windows\CurrentVersion\Network\LanMan\'; - Reg_RCC.OpenKeyReadOnly(ChaveRegistro); - Reg_RCC.GetKeyNames(Lista_RCC); - Reg_RCC.CloseKey; - For I := 0 To Lista_RCC.Count - 1 Do - Begin - nm_compartilhamento := Lista_RCC.Strings[i]; - Reg_RCC.OpenKey(ChaveRegistro + nm_compartilhamento, True); - nm_dir_compart := Reg_RCC.ReadString('Path'); - te_comentario := Reg_RCC.ReadString('Remark'); - if (Reg_RCC.GetDataSize('Parm1enc') = 0) Then in_senha_escrita := '0' Else in_senha_escrita := '1'; - if (Reg_RCC.GetDataSize('Parm2enc') = 0) Then in_senha_leitura := '0' Else in_senha_leitura := '1'; - if (Reg_RCC.ReadInteger('Type') = 0) Then cs_tipo_compart := 'D' Else cs_tipo_compart := 'I'; - intAux := Reg_RCC.ReadInteger('Flags'); - Case intAux of //http://www.la2600.org/talks/chronology/enigma/19971107.html - 401 : cs_tipo_permissao := 'S'; // Somente Leitura. - 258 : cs_tipo_permissao := 'C'; // Completo. - 259 : cs_tipo_permissao := 'D'; // Depende de senha. - end; - Reg_RCC.CloseKey; - strXML := strXML + '' + - '' + nm_compartilhamento + '' + - '' + nm_dir_compart + '' + - '' + cs_tipo_compart + '' + - '' + cs_tipo_permissao + '' + - '' + in_senha_leitura + '' + - '' + in_senha_escrita + '' + - '' + te_comentario + '' + - ''; - end; - end; - - if (Lista_RCC.Count = 0) then strXML := strXML + '' + - '' + - '' + - '' + - '' + - ''; - - Reg_RCC.Free; - Lista_RCC.Free; - strXML := strXML + ''; - // Obtenho do registro o valor que foi previamente armazenado - ValorChaveRegistro := Trim(GetValorChaveRegIni('Coleta','Compartilhamentos',p_path_cacic_ini)); - // Se essas informações forem diferentes significa que houve alguma alteração - // na configuração. Nesse caso, gravo as informações no BD Central e, se não houver - // problemas durante esse procedimento, atualizo as informações no registro. - If (GetValorChaveRegIni('Configs','IN_COLETA_FORCADA_COMP',p_path_cacic_ini)='S') or (strXML <> ValorChaveRegistro) Then - Begin - frmcol_comp.SetValorChaveRegIni('Col_Comp','Compartilhamentos', strXML, frmcol_comp.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_comp.ini'); - End - else frmcol_comp.SetValorChaveRegIni('Col_Comp','nada', 'nada', frmcol_comp.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_comp.ini'); - application.Terminate; - Except - frmcol_comp.SetValorChaveRegIni('Col_Comp','nada', 'nada', frmcol_comp.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_comp.ini'); - application.Terminate; - End; -end; - -procedure Tfrmcol_comp.FormCreate(Sender: TObject); -var tstrTripa1 : TStrings; - intAux : integer; -begin - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini - tstrTripa1 := explode(ExtractFilePath(Application.Exename),'\'); - p_path_cacic := ''; - For intAux := 0 to tstrTripa1.Count -2 do - begin - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\'; - end; - p_path_cacic_ini := p_path_cacic + 'cacic2.ini'; - Application.ShowMainForm := false; - Try - Executa_Col_comp; - Except - frmcol_comp.SetValorChaveRegIni('Col_Comp','nada', 'nada', frmcol_comp.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_comp.ini'); - application.Terminate; - End; -end; - -end. - -- libgit2 0.21.2