Beginning of FTP uploads
This commit is contained in:
parent
7e25a22a71
commit
6db36536ed
|
@ -48,11 +48,11 @@ Type
|
||||||
Procedure Execute; Override;
|
Procedure Execute; Override;
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
|
|
||||||
|
Function OpenDataSession : Boolean;
|
||||||
|
Procedure CloseDataSession;
|
||||||
Procedure ResetSession;
|
Procedure ResetSession;
|
||||||
Procedure UpdateUserStats (TFBase: RecFileBase; FDir: RecFileList; DirPos: LongInt);
|
Procedure UpdateUserStats (TFBase: RecFileBase; FDir: RecFileList; DirPos: LongInt);
|
||||||
Function CheckFileLimits (TempFBase: RecFileBase; FDir: RecFileList) : Byte;
|
Function CheckFileLimits (TempFBase: RecFileBase; FDir: RecFileList) : Byte;
|
||||||
Function OpenDataSession : Boolean;
|
|
||||||
Procedure CloseDataSession;
|
|
||||||
Function ValidDirectory (TempBase: RecFileBase) : Boolean;
|
Function ValidDirectory (TempBase: RecFileBase) : Boolean;
|
||||||
Function FindDirectory (Var TempBase: RecFileBase) : LongInt;
|
Function FindDirectory (Var TempBase: RecFileBase) : LongInt;
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ Type
|
||||||
Procedure cmdLIST;
|
Procedure cmdLIST;
|
||||||
Procedure cmdPWD;
|
Procedure cmdPWD;
|
||||||
Procedure cmdRETR;
|
Procedure cmdRETR;
|
||||||
|
Procedure cmdSTOR;
|
||||||
Procedure cmdSTRU;
|
Procedure cmdSTRU;
|
||||||
Procedure cmdMODE;
|
Procedure cmdMODE;
|
||||||
Procedure cmdSYST;
|
Procedure cmdSYST;
|
||||||
|
@ -497,14 +498,17 @@ Begin
|
||||||
If LoggedIn Then Begin
|
If LoggedIn Then Begin
|
||||||
If (Data = '/') or (Copy(Data, 1, 2) = '..') Then Begin
|
If (Data = '/') or (Copy(Data, 1, 2) = '..') Then Begin
|
||||||
FBasePos := -1;
|
FBasePos := -1;
|
||||||
|
|
||||||
Client.WriteLine(re_DirOkay + '"/"');
|
Client.WriteLine(re_DirOkay + '"/"');
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
TempPos := FindDirectory(TempBase);
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
If TempPos = -1 Then Begin
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
Client.WriteLine(re_BadDir);
|
Client.WriteLine(re_BadDir);
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -526,10 +530,10 @@ Begin
|
||||||
If LoggedIn Then Begin
|
If LoggedIn Then Begin
|
||||||
TempPos := FindDirectory(TempBase);
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
If TempPos = -1 Then Begin
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
OpenDataSession;
|
OpenDataSession;
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
// list files in root directory, so show nothing
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -608,6 +612,12 @@ Begin
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
If Not ValidDirectory(TempBase) Then Begin
|
||||||
|
Client.WriteLine(re_BadCommand);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
OpenDataSession;
|
OpenDataSession;
|
||||||
|
|
||||||
DirFile := TFileBuffer.Create(FileBufSize);
|
DirFile := TFileBuffer.Create(FileBufSize);
|
||||||
|
@ -633,6 +643,38 @@ Begin
|
||||||
Client.WriteLine(re_BadCommand);
|
Client.WriteLine(re_BadCommand);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Procedure TFTPServer.cmdSTOR;
|
||||||
|
Var
|
||||||
|
TempPos : LongInt;
|
||||||
|
TempBase : RecFileBase;
|
||||||
|
Begin
|
||||||
|
If Not LoggedIn Then Begin
|
||||||
|
Client.WriteLine(re_BadCommand);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
|
Client.WriteLine(re_BadFile);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Client.WriteLine(re_BadFile);
|
||||||
|
|
||||||
|
//reasons why i haven't finished this (todo):
|
||||||
|
|
||||||
|
// ratios
|
||||||
|
// diskspace
|
||||||
|
// archive testing
|
||||||
|
// file_id.diz importing
|
||||||
|
// forcing uploads to upload base (if non-zero)
|
||||||
|
// duplicate file checking
|
||||||
|
// upload statistic tracking
|
||||||
|
End;
|
||||||
|
|
||||||
Procedure TFTPServer.cmdRETR;
|
Procedure TFTPServer.cmdRETR;
|
||||||
Var
|
Var
|
||||||
TempPos : LongInt;
|
TempPos : LongInt;
|
||||||
|
@ -833,10 +875,11 @@ Begin
|
||||||
If Cmd = 'PASS' Then cmdPASS Else
|
If Cmd = 'PASS' Then cmdPASS Else
|
||||||
If Cmd = 'PASV' Then cmdPASV Else
|
If Cmd = 'PASV' Then cmdPASV Else
|
||||||
If Cmd = 'PORT' Then cmdPORT Else
|
If Cmd = 'PORT' Then cmdPORT Else
|
||||||
If Cmd = 'PWD' Then cmdPWD ELse
|
If Cmd = 'PWD' Then cmdPWD Else
|
||||||
If Cmd = 'REIN' Then cmdREIN Else
|
If Cmd = 'REIN' Then cmdREIN Else
|
||||||
If Cmd = 'RETR' Then cmdRETR Else
|
If Cmd = 'RETR' Then cmdRETR Else
|
||||||
If Cmd = 'SIZE' Then cmdSIZE Else
|
If Cmd = 'SIZE' Then cmdSIZE Else
|
||||||
|
If Cmd = 'STOR' Then cmdSTOR Else
|
||||||
If Cmd = 'STRU' Then cmdSTRU Else
|
If Cmd = 'STRU' Then cmdSTRU Else
|
||||||
If Cmd = 'SYST' Then cmdSYST Else
|
If Cmd = 'SYST' Then cmdSYST Else
|
||||||
If Cmd = 'TYPE' Then cmdTYPE Else
|
If Cmd = 'TYPE' Then cmdTYPE Else
|
||||||
|
|
Loading…
Reference in New Issue