PHP Classes

PHP FTP Sync: Synchronize files and folders over FTP

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 64%Total: 1,808 All time: 2,174 This week: 488Up
Version License PHP version Categories
ftp-sync 1.0.1Free for non-comm...5.0Networking, PHP 5, Files and Folders
Description 

Author

This class can synchronize files and folders over FTP.

It connects to a given FTP server and it knows how to synchronize files of a local folder with the remote files of a folder in the FTP server.

The class only copies the new and modified local files to the remote server after last time folder synchronization was run.

It can also exclude a given list of directories and files from being synchronized.

Picture of John Saman
  Performance   Level  
Name: John Saman <contact>
Classes: 1 package by
Country: Egypt Egypt
Age: 39
All time rank: 161314 in Egypt Egypt
Week rank: 321 Up7 in Egypt Egypt Up

Example

<?php
/*
    File : FTP_SYNC_EXAMPLE.PHP
    Ver. : 1.0.0
    Desc.: The class is made to work as an alternative to rsync when FTP is only available.
        The class use FTP to do synchronization to the target FTP host.
        It copies only the new and modified files after last run of the script.
        You can specify exclude list to the class and any directories or files in this list will be ignored from synchronization.

    Developed By John Saman (jsaman.59@gmail.com)
    Used and owned by www.ephotobay.com
    Licensed Under Non-Profit Open Software License 3.0 (Non-Profit OSL 3.0)
*/

include_once 'ftp_sync.php';

$ftpServer='hostname';
$ftpUsername='username';
$ftpPassword='password';

//max simulatnous connections. the more of this number the faster synchronization will be but if set to high number it'll be aborted by FTP server probably so try to keep it in between.
//Note: if it's getting connection refused error try to set this number to low number usually 5 should be fine.
$maxConnections=5;

//a comma separated list of folder names or file names - full name is required
$exclude_list='cache,template_c';

$sync=new FTPSync($ftpServer,$ftpUsername,$ftpPassword,$maxConnections,$exclude_list);

//This to display detailed information about the directories and files being uploaded - use for testing
$sync->verbose=true;

//start synchronization process
$sync->syncRemoteDir('/path/to/local','/path/to/remote');

?>


Details

Notes before using this class:- 1- Please don't write ftp:// before the host name or it will fail. 2- If you had troubles connecting to the FTP server or if the synchronization is taking too long try decreasing the number of maxConnections to 1 or 2 because some servers refuse multiple connections from the same client. 3- Some servers doesn't support chmod options so you may get errors like PHP Warning: ftp_chmod(): Unknown SITE command. Just can ignore this error

  Files folder image Files  
File Role Description
Plain text file ftp_sync.php Class FTP Synchronizer Class
Accessible without login Plain text file ftp_sync_example.php Example FTP Synchronizer Example
Accessible without login Plain text file readme.txt Doc. Please read this file before using the class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,808
This week:0
All time:2,174
This week:488Up
User Ratings User Comments (1)
 All time
Utility:83%StarStarStarStarStar
Consistency:79%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:64%StarStarStarStar
Rank:692
 
Top, exactly what i wanted.
6 years ago (Pitt Roscher)
77%StarStarStarStar