fix : change and fix SyncService
This commit is contained in:
parent
7e8aa185ab
commit
ea82f5968e
|
|
@ -172,7 +172,7 @@ private function transferFilesViaFtp(array $changes, string $side, array &$repor
|
|||
continue;
|
||||
}
|
||||
@ftp_mkdir($ftp, $remoteFolder);
|
||||
if (ftp_put($ftp, $remoteFile, $localFile, FTP_BINARY)) {
|
||||
if (@ftp_put($ftp, $remoteFile, $localFile, FTP_BINARY)) {
|
||||
$report[] = "فایل [{$filePath}] ارسال شد (FTP) ✓";
|
||||
} else {
|
||||
$report[] = "فایل [{$filePath}] ارسال نشد (FTP) ✗";
|
||||
|
|
@ -185,7 +185,7 @@ private function transferFilesViaFtp(array $changes, string $side, array &$repor
|
|||
if (! is_dir($localFolder)) {
|
||||
mkdir($localFolder, 0755, true);
|
||||
}
|
||||
if (ftp_get($ftp, $localFile, $remoteFile, FTP_BINARY)) {
|
||||
if (@ftp_get($ftp, $localFile, $remoteFile, FTP_BINARY)) {
|
||||
$report[] = "فایل [{$filePath}] دریافت شد (FTP) ✓";
|
||||
} else {
|
||||
$report[] = "فایل [{$filePath}] دریافت نشد (FTP) ✗";
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ function ftpSession($ctrl, string $user, string $pass, string $root): void
|
|||
case 'PASV':
|
||||
if (!$authed) { ftpSend($ctrl, '530 Not logged in'); break; }
|
||||
if ($pasvSock) fclose($pasvSock);
|
||||
$pasvPort = rand(49152, 65534);
|
||||
$pasvPort = rand(60000, 60020); // fixed range — must match firewall rule
|
||||
$pasvSock = @stream_socket_server("tcp://0.0.0.0:{$pasvPort}", $e1, $e2);
|
||||
if (!$pasvSock) { ftpSend($ctrl, '425 Cannot open passive connection'); break; }
|
||||
$localAddr = stream_socket_get_name($ctrl, false);
|
||||
|
|
@ -220,15 +220,13 @@ function ftpSession($ctrl, string $user, string $pass, string $root): void
|
|||
$full = $root . $p;
|
||||
$dir = dirname($full);
|
||||
if (!is_dir($dir)) mkdir($dir, 0755, true);
|
||||
$fp = @fopen($full, 'wb');
|
||||
if (!$fp) { ftpSend($ctrl, '550 Cannot write file'); break; }
|
||||
$data = ftpOpenData($pasvSock);
|
||||
if (!$data) { ftpSend($ctrl, '425 No data connection'); break; }
|
||||
if (!$data) { fclose($fp); ftpSend($ctrl, '425 No data connection'); break; }
|
||||
ftpSend($ctrl, '150 Ready to receive');
|
||||
$fp = fopen($full, 'wb');
|
||||
if (!$fp) { fclose($data); ftpSend($ctrl, '550 Cannot write file'); break; }
|
||||
while (!feof($data)) {
|
||||
$buf = fread($data, 65536);
|
||||
if ($buf !== false && $buf !== '') fwrite($fp, $buf);
|
||||
}
|
||||
stream_set_timeout($data, 30);
|
||||
stream_copy_to_stream($data, $fp);
|
||||
fclose($fp);
|
||||
fclose($data);
|
||||
echo " STOR: {$p} (" . number_format(filesize($full)) . " bytes)\n";
|
||||
|
|
|
|||
|
|
@ -34,22 +34,34 @@ if not exist "!SCRIPTS!\php\php-cgi.exe" (
|
|||
pause & exit /b 1
|
||||
)
|
||||
|
||||
REM --- [1/6] storage:link ---
|
||||
echo [1/6] Creating storage link...
|
||||
REM --- [1/7] Clear bootstrap cache ---
|
||||
echo [1/7] Clearing bootstrap cache...
|
||||
cd /d "!PROJECT_DIR!"
|
||||
if exist "bootstrap\cache\config.php" del /F /Q "bootstrap\cache\config.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\routes-v7.php" del /F /Q "bootstrap\cache\routes-v7.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\services.php" del /F /Q "bootstrap\cache\services.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\packages.php" del /F /Q "bootstrap\cache\packages.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\events.php" del /F /Q "bootstrap\cache\events.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\blade-icons.php" del /F /Q "bootstrap\cache\blade-icons.php" >nul 2>&1
|
||||
if exist "bootstrap\cache\filament" rmdir /S /Q "bootstrap\cache\filament" >nul 2>&1
|
||||
echo [OK] Done.
|
||||
echo.
|
||||
|
||||
REM --- [2/7] storage:link ---
|
||||
echo [2/7] Creating storage link...
|
||||
"!SCRIPTS!\php\php.exe" artisan storage:link >nul 2>&1
|
||||
echo [OK] Done.
|
||||
echo.
|
||||
|
||||
REM --- [2/6] Optimize Laravel ---
|
||||
echo [2/6] Optimizing Laravel...
|
||||
REM --- [3/7] Optimize Laravel ---
|
||||
echo [3/7] Optimizing Laravel...
|
||||
"!SCRIPTS!\php\php.exe" artisan optimize --quiet 2>nul
|
||||
"!SCRIPTS!\php\php.exe" artisan filament:optimize --quiet 2>nul
|
||||
echo [OK] Done.
|
||||
echo.
|
||||
|
||||
REM --- [3/6] Configure OPcache ---
|
||||
echo [3/6] Configuring OPcache...
|
||||
REM --- [4/7] Configure OPcache ---
|
||||
echo [4/7] Configuring OPcache...
|
||||
if not exist "C:\tmp\php-opcache" mkdir "C:\tmp\php-opcache"
|
||||
set "SCRIPTS_BAK=!SCRIPTS!"
|
||||
powershell -NoProfile -Command ^
|
||||
|
|
@ -57,8 +69,8 @@ powershell -NoProfile -Command ^
|
|||
echo [OK] Done.
|
||||
echo.
|
||||
|
||||
REM --- [4/6] Generate nginx.conf from template ---
|
||||
echo [4/6] Writing nginx.conf...
|
||||
REM --- [5/7] Generate nginx.conf from template ---
|
||||
echo [5/7] Writing nginx.conf...
|
||||
set "PUBLIC_DIR=!PROJECT_DIR:\=/!/public"
|
||||
if not exist "!SCRIPTS!\nginx\conf\nginx.conf.template" (
|
||||
echo [ERROR] nginx.conf.template not found in scripts\nginx\conf\
|
||||
|
|
@ -69,17 +81,19 @@ powershell -NoProfile -Command ^
|
|||
echo [OK] nginx.conf written.
|
||||
echo.
|
||||
|
||||
REM --- [5/6] Firewall ---
|
||||
echo [5/6] Firewall rules...
|
||||
netsh advfirewall firewall delete rule name="Matab Web 8000" >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="Matab FTP 2121" >nul 2>&1
|
||||
netsh advfirewall firewall add rule name="Matab Web 8000" dir=in action=allow protocol=TCP localport=8000 >nul
|
||||
netsh advfirewall firewall add rule name="Matab FTP 2121" dir=in action=allow protocol=TCP localport=2121 >nul
|
||||
REM --- [6/7] Firewall ---
|
||||
echo [6/7] Firewall rules...
|
||||
netsh advfirewall firewall delete rule name="Matab Web 8000" >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="Matab FTP 2121" >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="Matab FTP Passive" >nul 2>&1
|
||||
netsh advfirewall firewall add rule name="Matab Web 8000" dir=in action=allow protocol=TCP localport=8000 >nul
|
||||
netsh advfirewall firewall add rule name="Matab FTP 2121" dir=in action=allow protocol=TCP localport=2121 >nul
|
||||
netsh advfirewall firewall add rule name="Matab FTP Passive" dir=in action=allow protocol=TCP localport=60000-60020 >nul
|
||||
echo [OK] Done.
|
||||
echo.
|
||||
|
||||
REM --- [6/6] Windows Services ---
|
||||
echo [6/6] Installing Windows services...
|
||||
REM --- [7/7] Windows Services ---
|
||||
echo [7/7] Installing Windows services...
|
||||
|
||||
echo Stopping old services...
|
||||
"!WINSW!" stop "!SCRIPTS!\matab-autostart.xml" >nul 2>&1
|
||||
|
|
|
|||
Loading…
Reference in New Issue