📄 srvctrl.pas
字号:
LogMessage(CS_DLOAD);
end
else
begin
DTrd.Terminate;
SendString('425 Can''t open data connection.');
end;
end;
16: { STOU }
begin
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
{ Checking the directory permissions }
if s = '' then
s:=CDir
else
if not (s[1] in ['/','\']) then
s:=addslash(CDir)+s;
s:=NormalizePath(s);
i:=Parent.DirList.IndexOf(s);
randomize;
s1:=format('%4.4u%4.4u.TMP',[random(9999),random(9999)]);
if i < 0 then
begin
SendString('450 Directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrWriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_WriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
end;
{ Run the data process }
s:=addslash(Parent.DirList.Alias[i])+s1;
if DCon then
begin
DTrd.GotWork(s,di_RECEIVE,CMode,CData,nil,Marker);
SendString('125 '+s1);
end
else
begin
DTrd:=TDataThread.Create(s,RAddr,Pasv,di_RECEIVE,CMode,CData,DPort,
Parent,nil,Marker,DConExit,ControlLog,Usr,Pwd,CDir);
DCon:=true;
SendString('150 '+s1);
end;
if DTrd.Error = 0 then
begin
State:=st_DATA;
TOut:=TTimeout.create(72000,@Brk);
LogMessage(CS_DLOAD);
end
else
begin
DTrd.Terminate;
SendString('425 Can''t open data connection.');
end;
end;
17: { APPE }
begin
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
{ Checking the directory permissions }
par:=alltrim(par);
if par[length(par)] in ['/','\'] then
begin
SendString('450 No file name specified');
continue;
end;
s:=par;
while (s <> '') and not (s[length(s)] in ['\','/']) do dec(byte(s[0]));
s1:=copy(par,length(s)+1,255);
if s = '' then
s:=CDir
else
if not (s[1] in ['/','\']) then
s:=addslash(CDir)+s;
s:=NormalizePath(s);
i:=Parent.DirList.IndexOf(s);
if i < 0 then
begin
SendString('450 Directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrWriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_WriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
end;
{ Run the data process }
s:=addslash(Parent.DirList.Alias[i])+s1;
s1:='';
case CMode of
md_ASCII: s1:='ASCII';
md_IMAGE: s1:='BINARY';
end;
if DCon then
begin
DTrd.GotWork(s,di_APPEND,CMode,CData,nil,Marker);
SendString('125 Gonna receive file in '+s1+' mode');
end
else
begin
DTrd:=TDataThread.Create(s,RAddr,Pasv,di_APPEND,CMode,CData,DPort,
Parent,nil,Marker,DConExit,ControlLog,Usr,Pwd,CDir);
DCon:=true;
SendString('150 Gonna receive file in '+s1+' mode');
end;
if DTrd.Error = 0 then
begin
State:=st_DATA;
TOut:=TTimeout.create(72000,@Brk);
LogMessage(CS_DLOAD);
end
else
begin
DTrd.Terminate;
SendString('425 Can''t open data connection.');
end;
end;
18: { ALLO }
begin
SendString('502 Command "'+cmd+'" not implemented');
end;
19: { REST }
begin
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
val(par,extint,i1);
if i1 > 0 then
SendString('501 Syntax error (bad marker)')
else
begin
Marker:=par;
SendString('350 Ready for transfer');
end;
end;
20: { RNFR }
begin
rnfr:='';
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
{ Checking file permissions }
par:=alltrim(par);
if (pos('\',par) > 0) or (pos('/',par) > 0) then
begin
SendString('501 Path is not allowed');
continue;
end;
s:=NormalizePath(CDir);
i:=Parent.DirList.IndexOf(s);
if i < 0 then
begin
SendString('450 Directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrReadFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_ReadFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
end;
s:=addslash(Parent.DirList.Alias[i])+par;
if FindFirst(s,faArchive+faHidden+faReadOnly,SR) <> 0 then
begin
SendString('450 File not found');
continue;
end;
rnfr:=par;
SendString('350 Send RNTO');
end;
21: { RNTO }
begin
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
if rnfr = '' then
begin
SendString('503 No RNFR was given');
continue;
end;
s:=NormalizePath(CDir);
i:=Parent.DirList.IndexOf(s);
if i < 0 then
begin
SendString('450 Directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrReadFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_ReadFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
end;
s:=addslash(Parent.DirList.Alias[i]);
assignfile(f,s+par);
erase(f);
ioresult;
assignfile(f,s+rnfr);
rename(f,s+par);
if ioresult = 0 then
begin
SendString('250 Done');
end
else
begin
SendString('553 Requested action not taken');
end;
end;
22: { ABOR }
begin
if State <> st_DATA then
begin
SendString('226 Command ok.');
Continue;
end;
if DCon then
begin
DTrd.Terminate;
TOut:=TTimeout.create(50,@Brk);
while DCon and not Brk do;
if Brk then
HandleError(ES_DRUN)
else
TOut.terminate;
State:=st_DIALOG;
SendString('426 Data connection closed');
SendString('226 Command ok.');
end;
end;
23: { DELE }
begin
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
{ Checking the directory permissions }
par:=alltrim(par);
if par[length(par)] in ['/','\'] then
begin
SendString('450 No file name specified');
continue;
end;
s:=par;
while (s <> '') and not (s[length(s)] in ['\','/']) do dec(byte(s[0]));
s1:=copy(par,length(s)+1,255);
if s = '' then
s:=CDir
else
if not (s[1] in ['/','\']) then
s:=addslash(CDir)+s;
s:=NormalizePath(s);
i:=Parent.DirList.IndexOf(s);
if i < 0 then
begin
SendString('450 Directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrWriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_WriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
end;
{ Run the data process }
s:=addslash(Parent.DirList.Alias[i])+s1;
assignfile(f,s);
erase(f);
if ioresult = 0 then
begin
SendString('250 Done');
end
else
begin
SendString('553 Requested action not taken');
end;
end;
24: { RMD }
begin
{ Removes a virtual directory }
if (State <> st_DIALOG) and (State <> st_DATA) then
begin
SendString('530 Not logged in');
Continue;
end;
{ Checking the directory permissions }
par:=alltrim(par);
if par[length(par)] in ['/','\'] then setlength(par,length(par)-1);
s:=par;
while (s <> '') and not (s[length(s)] in ['\','/']) do dec(byte(s[0]));
s1:=copy(par,length(s)+1,255);
if s = '' then
s:=CDir
else
if not (s[1] in ['/','\']) then
s:=addslash(CDir)+s;
s:=NormalizePath(s);
i:=Parent.DirList.IndexOf(s);
if i < 0 then
begin
SendString('450 Parent directory not found');
continue;
end;
if not Parent.UserList.RootByName(Usr) then
begin
if Parent.DirList.UID[i] <> Parent.UserList.UIDByName(Usr) then
begin
if Parent.UserList.InGroupByName(Usr,Parent.DirList.GID[i]) then
begin
if not (da_GrWriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end
else
if not (da_WriteFiles in Parent.DirList.Attrib[i]) then
begin
SendString('550 Permission denied');
continue;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -