PHP FTP Synchronizer. Website
Free program for updating the website from local files. PHP FTP Synchronizer recursively scans the directory tree and updates the equivalent directory on the site, replacing modified files. It tests broken links on the page and updates the site map.
PHP FTP Synchronizer is a script with source code in the Script language and creates an executable PHP file. A Script 2 compiler is required to compile the source.
It works on the command line.
Program specifics
Compared to various existing and mostly commercial programs, the synchronizer offers acceleration options:
- It is possible to use a copy version on which comparisons are made, which avoids downloading the deleted file and thus provides a quick update. You can also create a second site backup, possibly on a removable storage device.
- The ability to migrate all modified files in the last n days, n is the number of days you specify.
In addition, the executable program is a PHP script, so it works on all systems, Windows, Linux, Mac... And you can empower it if you need to.
How the program works
Since the useful parameters are given (see below), the program has the path to your files, the name of the site (ftp.xxx.tld), your login and password, the path to the hosting, if you do not copy to the root, as well as the selected parameters.
It reads each file by recursively scanning the directory and subdirectories, compares it to the deleted one if it exists, and copies or replaces it.
If the acceleration option is selected, it compares the file with the backup when on a specific date or content of choice, and then, if they are different, downloads the file, copies it to the backup, and synchronizes the date of the backup file with the date of the source.
Installation
Download PHP and extract it to a directory, for example:
c:\php\
On Windows, this directory must be included in the PATH variable.
Type "env" in the search box on the taskbar, select "path" and click the edit button. Add this line:
c:\php\.
In the php directory, rename php.ini-production to php.ini
Add ftp extension. Edit this php.ini file to remove ";" before ftp in the extension list.
Using a Round
The links test is faster with curl and also allows you to check links to https .
To enable curl, delete ";" before the curl extension in php.ini.
To verify that this ini file is considered, type:
php --ini
This will give the path to the loaded ini file .
Memory limitation
If PHP tells you that the memory is saturated ("exported"), you can also increase the limit in php.ini:
memory_limit = 1024M
Using PHP FTP Synchronizer
The command line opens on Windows or the console opens on Linux or Mac.
We place an order in the form:
solp ftpsync [options] [paramètres] url
or directly in PHP:
php ftpsync.php [options] [paramètres] url
Texts enclosed in square brackets [] are optional.
Example:
php ftpsync.php -v -llogin -pmotdepass -fftp.example.com -dw:\example\ -bf:\example\ -wwww.example.com
The options detailed in the manual allow you to pass all the necessary parameters. If a parameter is missing, the program requests it. But if a parameter is selected that requires configuration, it must be specified in the command, the program does not ask for it, which in this case gives an error.
Program and Management
Guide to using PHP FTP Synchronizer.
Possible problems
- After a while, the program speeds up and wants to download all the files without distinction.
This is due to a lack of memory that allows PHP to make comparisons and select modified files.
You can increase the amount of memory allocated in the php.ini file, which is located in the Windows directory or equivalent on Unix, as well as the script execution time :max_execution_time = 3000 memory_limit = 1024M
- It is also possible that the server will close the connection if it lasts too long. A backup device is recommended.
- If you installed Windows Live OneCare, which restricts ftp translations, check the program before using it in production.
ftpsync [options] [options] dirsource [
url]phillag
webmaster
function main($argc, $argv)while it is called at the root of the script:
main($argc, $argv)these variables are global variables that are determined automatically. Only when calling a script using http (POST) commands, & etc. Parentheses are for guidance, not for programming. They are an optional parameter. In the actual order, the parentheses and their contents are replaced by the parameter.
Purpose and source
phillag
webmaster
php ftpsync.php h:/rep/sourep/ -llogin -pmonpasse -dwww ftp.example.comA URL is recognized as such if it starts with ftp.
Flip the job
hugo69
webmaster
if ftp_put(connection, rmt, src, $(FTP_BINARY)) = truevia the ftp_get function. But this will be accompanied by many other changes to the program. I am now too overwhelmed to think about this work myself...
hugo69
in principle, the function should be replaced ftp_putYes, I thought about it, but the problem is that all lust and checks are different locally and remotely... Therefore, you need to make a lot of changes... And instead of spending a few hours changing that scenario, I thought qqun must have had the same problem, t already adapted it or found a similar scenario... It would be so good, it would be better...if ftp_put(connection, rmt, src, $(FTP_BINARY)) = truevia the ftp_get function. But this will be accompanied by many other changes to the program. I am now too overwhelmed to think about this work myself...