Registriert seit: 2. Dez 2009
Ort: München
320 Beiträge
Lazarus
|
Re: Connection Closed Gracefully.
21. Dez 2009, 18:53
Hallo, als Brutalmethode kannst du folgendes verwenden!?
Delphi-Quellcode:
var
_Sync: TRTLCriticalSection;
procedure TServer.IdTCPServer1Execute(AThread: TIdContext);
var
Data : String;
StrArr : TDynStringArray;
ini : TIniFile;
f : TextFile;
Files : string;
y,m,d : Word;
begin
EnterCriticalSection(_Sync);
try
with AThread.Connection do
begin
DecodeDate(Now,d,m,y);
Files := Format('log\%.2d-%.2d-%.2d.txt',[y,m,d]);
AssignFile(f, Files);
try
if FileExists(Files) then Append(f) else Rewrite(f);
Data := String(Socket.ReadLn);
Data := Trim(Data);
if Length(Data) > 0 then
begin
StrArr := Explode('|', Data);
if StrArr[0] = 'login' then
begin
if StrArr[3] = Clientver then
begin
if FileExists('accounts\'+StrArr[1]+'.ini') then
begin
ini := TIniFile.Create('accounts\'+StrArr[1]+'.ini');
try
if StrArr[2] = ini.ReadString('Login','Passwort','') then
begin
Socket.WriteLn('login');
WriteLn('['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' hat sich eingeloggt.');
WriteLn(f, '['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' hat sich eingeloggt.');
end
else
begin
Socket.WriteLn('invalid');
WriteLn('['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' falsches Passwort.');
WriteLn(f, '['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' falsches Passwort.');
end;
finally
ini.free;
end;
end
else
begin
Socket.WriteLn('na');
WriteLn('['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' existiert nicht.');
WriteLn(f, '['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' existiert nicht.');
end;
end
else
begin
Socket.WriteLn('version');
end;
end;
if StrArr[0] = 'register' then
begin
if FileExists('accounts\'+StrArr[1]+'.ini') then
begin
Socket.WriteLn('vorhanden');
WriteLn('['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' existiert bereits.');
WriteLn(f, '['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' existiert bereits.');
end
else
begin
try
ini := TIniFile.Create('accounts\'+StrArr[1]+'.ini');
ini.WriteString('Login','Passwort',StrArr[2]);
ini.WriteString('Login','E-Mail',StrArr[3]);
finally
Socket.WriteLn('erfolg');
ini.free;
WriteLn('['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' wurde registriert.');
WriteLn(f, '['+TimeToStr(Time)+']'+' Account: '+StrArr[1]+' wurde registriert.');
end;
end;
end;
end;
end;
finally
CloseFile(f);
end;
finally
LeaveCriticalSection(_Sync);
end;
end;
initialization
DateSeparator := '.';
InitializeCriticalSection(_Sync);
finalization
DeleteCriticalSection(_Sync);
end.
lg. Astat
Lanthan Astat 06810110811210410503210511511603209711003210010110 9032084097103
03211611111604403209711003210010110903210010510103 2108101116122
11610103209010110510810103206711110010103210511003 2068101108112
10410503210310111509910411410510109810111003211910 5114100046
|
|
Zitat
|