procedure TMeinDienst.ServiceExecute(Sender: TService);
begin
//ShowMessage('OnExecute - begin');
while not Terminated
do
begin
TRY
// try to catch a user
if Username <> '
'
then
begin
// AUTOSCAN
// THIS SECTION IS FOR USER WHO JUST LOGGED IN
if (Username <> GetSession)
or (Welcome = False)
then
begin
ChangeUser;
if Username <> '
'
then // its important to get sure that the username has really been catched
begin
Welcome := True;
LogFile.Log(msg0004+GetIPAddress);
// check if the user already exists in the database
CheckDBforUser(ADOQuery1,ADOStoredProc1);
// Save to database that the user is logged in
UpdateUserInfo(Username, true);
// get all info from User Table "t_bb_user"
ADOQuery3.Close;
ADOQuery3.Parameters.ParamValues['
@username'] := username;
ADOQuery3.Open;
// If the logged in user is not on the blacklist it will autoscan now
if CheckUserOnBlacklist(Username) = False
then
begin
// autostart scan now, but first get defined scan_type from db!
case ADOQuery3scan_type.AsInteger
of
0:
begin ScanAndWriteToDB(True, stNoScanNoWrite);
end;
1:
begin ScanAndWriteToDB(True, stFullScanWriteJustRootFoldersSize);
end;
2:
begin ScanAndWriteToDB(True, stFullScanAndWrite);
end;
end;
end
else
begin
// user is on blacklist, but login info will be saved
ScanAndWriteToDB(True, stNoScanNoWrite);
LogFile.Log(Username+msg0016);
end;
// activate TCP server
if not assigned(TCPServer)
then
ActivateTCPServer;
end;
end
else if StartManScan
then
begin
try
// check if the user already exists in the database, else it will create him
if Username <> '
'
then
begin
CheckDBforUser(ADOQuery1,ADOStoredProc1);
ScanAndWriteToDB(False, stFullScanAndWrite);
end;
finally
// its very important to reset the variable StartManScan
StartManScan := False;
// send to the requesting host that the scan is complete now...
Connect;
TCPClient.IOHandler.WriteLn(IntToStr(CmdScanFinished));
// disconnect
Disconnect;
end;
end;
end
else
begin
ChangeUser;
Welcome := False;
end;
EXCEPT
on e:
Exception do
begin
LogFile.LOG(msg0000+e.
Message);
// maby there are some tcp actions pending...
Disconnect;
if fulllog
then LogFile.Log(msg0039);
end;
END;
ServiceThread.ProcessRequests(False);
Sleep(1000);
end;
//ShowMessage('OnExecute - end');
end;