PHP FTP Synchronizer, update a website from a local content
Free program to update your website from local files. PHP FTP Synchronizer traverses the tree structure of the source directory recursively and updates the file on the website, by replacing the files which were modified. It check for broken links in the page and update the sitemap.
PHP FTP Synchronizer is a script whose source code is writen in Scriptol language and compiled to PHP by the Scriptol 2 compiler available on this site.
Why use PHP FTP Synchronizer?
Compared to the various existing programs, commercial for the majority, the synchronizer offers speed options:
- Possible use of a backup version on which the comparisons are performed, what avoids downloading the remote file and allows an extremely fast update thus. Moreover that builds a second backup of the site, possibly on a removable storage unit.
- Possibility of uploading all files modified in n last days, n being a number of days that you define.
Moreover the executable program is a PHP script, it thus works on all operating systems, Windows, Linux, Mac... And you can extend its possibilities if needed.
How the program works
The required parameters being given (see below), the program has the location
of your files, the name of the site (in ftp.xxxx.tld form), login and password,
directory on hosting if one does not copy at root, as well as chosen options.
It reads each file by scanning in a recursive way the source directory and
the sub-directories, compares files with remote files if there exists, and
copies them or replaces them.
If the option of acceleration is selected, it compares the dates or contents
of file with the backup, and if they are different uploads the files, copies
them on the backup also and synchronizes the date of files in the backup with
that of sources.
Install
Download PHP and unzip in a directory, for example: c:\php\
Under Windows add this directory to the PATH variable.
Type "env" in the search field on the task bar, select "path" and click on the modify button. Add this line:
c:\php\.
In the php directory, rename the php.ini-production to php.ini
- Add the ftp extension. Edit php.ini to remove ";" before extension=ftp
- Activate also the curl extension.
- Verify the folder of extensions is well defined, for example:
extension_dir = "C:\php\ext"
Using curl
The link checker is faster with curl and it also allows to check https links.
To set curl active, remove ';' before curl among extensions in php.ini.
To verify that this ini file is one that is taken into account, type:
php --ini
This will give the path of the ini file loaded.
Memory limit
If the php writes that the memory is exhausted, you can change also the memory limit in the php.ini file.
memory_limit = 1024M
How to use the synchronizer
One opens a DOS Windows or a console under Linux or Mac.
Type this command:
php ftpsync.php [options]
Texts in brackets [] are optional.
Example:
php ftpsync.php -v -llogin -ppassword -fftp.example.com -dw:\example\ -bf:\example\ -wwww.example.com
The options which are detailed in the handbook allow to pass all the required parameters. If a parameter misses, the program prompt you for it. But if an option is given and that must be followed by a string, this one must be provided in order, it is not asked by the program which in this case displays an error.
Manual of PHP FTP Synchronizer.
Getting the program
The archive contains:
- The Scriptol source.
- The PHP executable script,
- The manual in HTML format, and ODF, you can create a PDF or Word's DOC file with Open Office.
- The ftpcheck script to verify a connection.
- The GPL licence.
Last changes in versions
- 3.2.1. September 2025
Error codes 503 are now ignored. - 3.2. March 23, 2024
Links with error code 303 or 403 (usually Youtube or Twitter) are now longer displayed. - 3.1. February 3, 2016.
Https URLs now are correctly checked.
Fixed the URL in the sitemap when the remote target is a subdirectory. - 3.0. October 5, 2016.
Updates the site map (in sitemap.xml) for the pages uploaded.
Displays the state or curl, enabled or not. - 2.2. July 1, 2016.
Now uses curl.
Https links are recognized by the link checker.
Supports PHP 7. - 2.1. June 3, 2016. Simplified the code.
- 2.0. March 30, 2015. Source code rewritten in Scriptol 2 and PHP code compatible with PHP 5.5.
- 1.9. February 13, 2012. Link checker now does not display 302 temporary redirects.
- 1.8 - September 20, 2010. Link checker now handles links relative to the root.
- 1.5 - August 6, 2008. The link check is differed, and performed once all pages are updated.
- 1.4 - July 1, 2008. Results of link check more precise. Only the pages with broken links or redirects are now displayed.
- 1.3 - June 24, 2008. The -u options activates a link check inside last added or modified pages.
- 1.2 - December 13, 2007. Added the -f option for url without ftp prefix.
- 1.1 - September 24, 2007. Added the passive FTP mode.
- 1.0 - September 18, 2007. First release.
Troubleshootings
- Without backup, after some times the program could accelerates and wants
to upload all the files without distinction.
That comes from a lack of memory for the PHP interpreter to make the comparisons and to select the modified files.
One can increase the allocated memory in the php.ini file which is in the Windows directory or equivalent under Unix just as the execution time granted to scripts:max_execution_time = 3000 memory_limit = 1024M
- It is possible also that the server closes the connection if it works for a long time. Use a backup directory or the -n option preferably.
- If you have installed Windows Live Oncare, ftp transferts are limited, verify first the results of updates made by the program before to use it in production.
Link Checker on the server side
BlueRabbit
scriptol
Download
user301
scriptol
user301
scriptol
if saved = 0
backError(bpath)
else
if CONTFLAG
print "Files compared by content"
TOUCHFLAG = false
return
/if
TOUCHFLAG = touch(convertUnix(tempfile), time())
unlink(tempfile)
if not QUIET
if TOUCHFLAG
print "Files compared by time"
else
print "Touch failed, files compared by contents"
/if
/if
/if
The CONTFLAG bypasses a code that perfoms a kind of comparison by time. I just realized that she has performed the comparison on a temp file.
To solve your problem, you should compare the time for the remote file with the filemtime() function that works with some protocols, according to the PHP doc.
Unfortunally, not all servers support this feature. You have to test the result on your server first:
echo filemtime(some url);and this function has to be updated:
void checkRemote(text rpath) TOUCHFLAG = filemtime(rpath) != false returnand the comparison of files too:
boolean filecompare(text a, text b) return filemtime(a) > filemtime(b)
user301
scriptol
Folders
fetto
scriptol
set PATH=%PATH%;c:\PHP\This could be set automatically by the installer. Let me know if it works in the way or if you get error messages. For FAM, it is not part of the standard build, so I can not add it to the script that must run on any configuration. It must be added by the user.
fetto
scriptol
php ftpsync.php -llogin -ppassword C:\xampp\htdocs\test ftp.xxxx.com -d/remotedir -bd:\backupdirlogin: the ftp login password: the ftppassword followed by the local directory ftp.xxxx.com the ftp URL remotedir the directory on the server, often htdocs or www d:\backupdir a drive and directory for a backup of the local image of the site, actually a backup of c:\xampp\htdocs\test
fetto
scriptol
Entering Passive Mode
alexSherby
Warning: ftp_put (): Entering Passive Mode (x, x, x, x, x, x) .. in /home/ftpsync/ftpsync.php on line 215Can you help me understand what is happening? Thank you
scriptol
alexSherby
scriptol
max_execution_time = 3600The default of 30 seconds is not enough. Must be 3600 at least. No reason to limit locally the execution time!
memory_limit = 1024MThe default 128 mega seems enough, but actually this is often too small. Increase it to 1024M. This does suppress two reasons that impeach a script to run properly.

