mysticbbs/mystic/mis_client_http.pas

128 lines
3.0 KiB
ObjectPascal
Raw Permalink Normal View History

// ====================================================================
// Mystic BBS Software Copyright 1997-2013 By James Coyle
// ====================================================================
//
// This file is part of Mystic BBS.
//
// Mystic BBS 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 3 of the License, or
// (at your option) any later version.
//
// Mystic BBS 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 Mystic BBS. If not, see <http://www.gnu.org/licenses/>.
//
// ====================================================================
2012-02-14 08:07:26 -08:00
Unit MIS_Client_HTTP;
2012-06-30 17:23:39 -07:00
{$I M_OPS.PAS}
2012-02-13 16:53:02 -08:00
Interface
Uses
2012-06-30 17:23:39 -07:00
MD5,
Classes,
2012-02-13 16:53:02 -08:00
SysUtils,
m_Strings,
m_FileIO,
2013-05-25 10:56:32 -07:00
m_io_Sockets,
2012-02-13 16:53:02 -08:00
m_DateTime,
MIS_Server,
MIS_NodeData,
2012-06-30 17:23:39 -07:00
MIS_Common,
BBS_MsgBase_ABS,
BBS_MsgBase_JAM,
BBS_MsgBase_Squish;
2012-02-13 16:53:02 -08:00
2013-05-25 10:56:32 -07:00
Function CreateHTTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TIOSocket) : TServerClient;
2012-02-13 16:53:02 -08:00
Type
2012-06-30 17:23:39 -07:00
THTTPServer = Class(TServerClient)
Server : TServerManager;
UserName : String[30];
LoggedIn : Boolean;
GotQuit : Boolean;
Cmd : String;
Data : String;
2012-02-13 16:53:02 -08:00
2013-05-25 10:56:32 -07:00
Constructor Create (Owner: TServerManager; CliSock: TIOSocket);
2012-02-13 16:53:02 -08:00
Procedure Execute; Override;
Destructor Destroy; Override;
Procedure ResetSession;
End;
Implementation
2013-05-25 10:56:32 -07:00
Function CreateHTTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TIOSocket) : TServerClient;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
Result := THTTPServer.Create(Owner, CliSock);
2012-02-13 16:53:02 -08:00
End;
2013-05-25 10:56:32 -07:00
Constructor THTTPServer.Create (Owner: TServerManager; CliSock: TIOSocket);
2012-02-13 16:53:02 -08:00
Begin
Inherited Create(Owner, CliSock);
Server := Owner;
End;
2012-06-30 17:23:39 -07:00
Procedure THTTPServer.ResetSession;
Var
Count : LongInt;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
LoggedIn := False;
GotQuit := False;
2012-02-13 16:53:02 -08:00
End;
2012-06-30 17:23:39 -07:00
Procedure THTTPServer.Execute;
2012-02-13 16:53:02 -08:00
Var
Str : String;
Begin
ResetSession;
2012-06-30 17:23:39 -07:00
// Client.WriteLine(re_Greeting);
2012-02-13 16:53:02 -08:00
Repeat
2012-06-30 17:23:39 -07:00
If Client.WaitForData(60 * 1000) = 0 Then Break;
2012-02-13 16:53:02 -08:00
If Terminated Then Exit;
If Client.ReadLine(Str) = -1 Then Exit;
Cmd := strUpper(strWordGet(1, Str, ' '));
If Pos(' ', Str) > 0 Then
Data := strStripB(Copy(Str, Pos(' ', Str) + 1, Length(Str)), ' ')
Else
Data := '';
2012-06-30 17:23:39 -07:00
If Cmd = 'QUIT' Then Begin
GotQuit := True;
2013-05-25 10:56:32 -07:00
2012-06-30 17:23:39 -07:00
Break;
End Else
2012-02-13 16:53:02 -08:00
Client.WriteLine(re_UnknownCommand);
Until Terminated;
2012-06-30 17:23:39 -07:00
If GotQuit Then Begin
Client.WriteLine(re_Goodbye);
Server.Server.Status (User.Handle + ' logged out');
End;
2012-02-13 16:53:02 -08:00
End;
2012-06-30 17:23:39 -07:00
Destructor THTTPServer.Destroy;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
ResetSession;
2012-02-13 16:53:02 -08:00
Inherited Destroy;
End;
End.