desarrollosconsejeria/adtos-server/1.7-0/adtos/clenviarcarpeta.pas @ 23a384b9
54e95a47 | Elisa | {
|
|
23a384b9 | Elisa | Adtos 1.0 Software de gestión de Aulas Tecnológicas
|
|
Copyright (C) 2008-2009, Consejería de Educación,Junta de Extremadura
|
|||
54e95a47 | Elisa | Programación: Manuel Narváez Martínez <mnarvaez007@gmail.com>
|
|
Diseño gráfico: Ana María Zamora Moreno
|
|||
Desarrollado con Lazarus 0.9.26
|
|||
This program is free software; you can redistribute it and/or modify
|
|||
it under the terms of the GNU General Public License as published by
|
|||
the Free Software Foundation; either version 2 of the License, or
|
|||
(at your option) any later version.
|
|||
This program is distributed in the hope that it will be useful,
|
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
|||
along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
}
|
|||
unit clenviarcarpeta;
|
|||
{$mode objfpc}{$H+}
|
|||
interface
|
|||
uses
|
|||
23a384b9 | Elisa | globales,Classes, SysUtils,IdSSLOpenSSL,IdTCPClient;
|
|
54e95a47 | Elisa | ||
type
|
|||
ThrEnviarCarpeta = class(TThread)
|
|||
private
|
|||
{ Private declarations }
|
|||
fnequipo:integer;
|
|||
fcarpeta:string;
|
|||
fhost,fcomando:string;
|
|||
23a384b9 | Elisa | fIdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
|
|
54e95a47 | Elisa | fcliente:TIdTcpClient;
|
|
fPuerto:integer;
|
|||
protected
|
|||
procedure Execute; override;
|
|||
public
|
|||
constructor Create(nequipo:integer;host,comando,carpeta:string);
|
|||
end;
|
|||
implementation
|
|||
constructor ThrEnviarCarpeta.Create(nequipo:integer;host,comando,carpeta:string);
|
|||
begin
|
|||
inherited Create(true);
|
|||
fnequipo:=nequipo;
|
|||
fhost:=host;
|
|||
FreeOnTerminate:=True;
|
|||
fcarpeta:=carpeta;
|
|||
fcomando:=comando;
|
|||
fPuerto:=PUERTO_USUARIO;
|
|||
end;
|
|||
procedure ThrEnviarCarpeta.Execute;
|
|||
var
|
|||
archivo:string;
|
|||
padre:string;
|
|||
23a384b9 | Elisa | micarpeta:string;
|
|
54e95a47 | Elisa | orden:string;
|
|
lstream:TFileStream;
|
|||
begin
|
|||
try
|
|||
micarpeta:=ExtractFileName(fcarpeta);
|
|||
padre:=ExtractFilePath(fcarpeta);
|
|||
23a384b9 | Elisa | orden:='cd "'+padre+'"; tar czvf adtos-carpeta'+inttostr(fnequipo)+'.tar.gz "'+micarpeta+'"';
|
|
54e95a47 | Elisa | Ejecutar(orden);
|
|
sleep(1000);
|
|||
23a384b9 | Elisa | archivo:=padre+'adtos-carpeta'+inttostr(fnequipo)+'.tar.gz';
|
|
54e95a47 | Elisa | lstream:= TFileStream.Create(archivo,fmOpenRead + fmShareDenyNone);
|
|
23a384b9 | Elisa | fIdSSLIOHandlerSocketOpenSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
|
fIdSSLIOHandlerSocketOpenSSL.Port:= fpuerto;
|
|||
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode:=sslmClient;
|
|||
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Method:=sslvSSLv3;
|
|||
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions:=[sslvSSLv3];
|
|||
54e95a47 | Elisa | fcliente:=TidTcpClient.create(nil);
|
|
23a384b9 | Elisa | fcliente.IOHandler:=fIdSSLIOHandlerSocketOpenSSL;
|
|
54e95a47 | Elisa | fcliente.Host:=fhost;
|
|
fcliente.port:=fPuerto;
|
|||
fcliente.connect;
|
|||
try
|
|||
fcliente.getResponse(200);
|
|||
fcliente.sendcmd(fcomando,253);
|
|||
fcliente.IOHandler.writebufferopen;
|
|||
fcliente.IOHandler.Write(lstream,0,true);
|
|||
fcliente.IOHandler.WriteBufferclose;
|
|||
finally
|
|||
begin
|
|||
fcliente.Disconnect;
|
|||
fcliente.free;
|
|||
23a384b9 | Elisa | fIdSSLIOHandlerSocketOpenSSL.Free;
|
|
54e95a47 | Elisa | lstream.free;
|
|
if fileexists(archivo) then
|
|||
deletefile(archivo);
|
|||
23a384b9 | Elisa | ||
54e95a47 | Elisa | end;
|
|
end;
|
|||
except
|
|||
23a384b9 | Elisa | writeln('Error al enviar carpeta');
|
|
54e95a47 | Elisa | end;
|
|
end;
|
|||
end.
|