check SyncService

This commit is contained in:
SajjadMahmoody 2026-04-18 03:03:21 +03:30
parent 693046bf5b
commit bbb727cffe
1 changed files with 32 additions and 1 deletions

View File

@ -106,11 +106,16 @@ function ftpSession($ctrl, string $user, string $pass, string $root): void
$pendUser = ''; $pendUser = '';
$pasvSock = null; $pasvSock = null;
stream_set_timeout($ctrl, 300);
ftpSend($ctrl, '220 matab-panel FTP Server'); ftpSend($ctrl, '220 matab-panel FTP Server');
while (!feof($ctrl)) { while (!feof($ctrl)) {
$line = ftpRead($ctrl); $line = ftpRead($ctrl);
if ($line === '') continue; if ($line === '') {
$info = stream_get_meta_data($ctrl);
if ($info['timed_out']) continue;
break;
}
$parts = explode(' ', $line, 2); $parts = explode(' ', $line, 2);
$cmd = strtoupper($parts[0]); $cmd = strtoupper($parts[0]);
@ -261,6 +266,31 @@ function ftpSession($ctrl, string $user, string $pass, string $root): void
} }
break; break;
case 'OPTS':
ftpSend($ctrl, '200 OK');
break;
case 'PBSZ':
ftpSend($ctrl, '200 PBSZ=0');
break;
case 'PROT':
ftpSend($ctrl, '200 Protection level set to ' . ($arg ?: 'C'));
break;
case 'EPSV':
if (!$authed) { ftpSend($ctrl, '530 Not logged in'); break; }
if ($pasvSock) fclose($pasvSock);
$pasvPort = rand(60000, 60020);
$pasvSock = @stream_socket_server("tcp://0.0.0.0:{$pasvPort}", $e1, $e2);
if (!$pasvSock) { ftpSend($ctrl, '425 Cannot open passive connection'); break; }
ftpSend($ctrl, "229 Entering Extended Passive Mode (|||{$pasvPort}|)");
break;
case 'EPRT':
ftpSend($ctrl, '200 OK');
break;
case 'NOOP': case 'NOOP':
ftpSend($ctrl, '200 OK'); ftpSend($ctrl, '200 OK');
break; break;
@ -270,6 +300,7 @@ function ftpSession($ctrl, string $user, string $pass, string $root): void
return; return;
default: default:
echo " [UNKNOWN CMD] {$cmd} {$arg}\n";
ftpSend($ctrl, '502 Not implemented: ' . $cmd); ftpSend($ctrl, '502 Not implemented: ' . $cmd);
} }
} }