1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer, IdFTPServer, IdTCPConnection, IdTCPClient, IdFTP, IdIPWatch;
type TForm1 = class(TForm) IdFTPServer1: TIdFTPServer; Button1: TButton; Button2: TButton; Edit1: TEdit; IdFTP1: TIdFTP; Button3: TButton; Button4: TButton; Edit2: TEdit; IdIPWatch1: TIdIPWatch; Edit3: TEdit; Edit4: TEdit; Label1: TLabel; Label2: TLabel; Edit5: TEdit; Label3: TLabel; Edit6: TEdit; Edit7: TEdit; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure IdFTPServer1UserLogin(ASender: TIdFTPServerThread; const AUsername, APassword: String; var AAuthenticated: Boolean); procedure IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); procedure IdFTPServer1Connect(AThread: TIdPeerThread);
private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IdFTPServer1UserLogin(ASender: TIdFTPServerThread; const AUsername, APassword: String; var AAuthenticated: Boolean); begin AAuthenticated := (AUsername = Edit3.Text) and (APassword = Edit4.Text); end;
procedure TForm1.Button1Click(Sender: TObject); begin IdFTPServer1.Active:=true; Edit1.Text:='aktiv'; end;
procedure TForm1.Button2Click(Sender: TObject); begin IdFTPServer1.Active:=false; Edit1.Text:='inaktiv'; end;
procedure TForm1.Button3Click(Sender: TObject); begin IdFTP1.Username:=Edit6.Text; IdFTP1.Password:=Edit7.Text; IdFTP1.Host:=IdIPWatch1.LocalIP; IdFTP1.Connect; Edit1.Text:=idftp1.Readln; end;
procedure TForm1.Button4Click(Sender: TObject); begin IdFTP1.Disconnect; Edit2.Text:='inaktiv'; end;
procedure TForm1.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); begin Edit2.Text:=AStatustext; end;
procedure TForm1.IdFTPServer1Connect(AThread: TIdPeerThread); var h: string; begin with Athread.Connection do begin writeln(h); end; end; end. |