-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftp-sync.php
42 lines (37 loc) · 1.07 KB
/
ftp-sync.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* This script is a "poor person's sync" system to copy files from one server to another. It uses FTP
* and builds a list of files on both sides, so that only changed files are copied. Normally we
* would use SSH/Rsync for this, but this is useful where such systems are not available.
*
* There is currently no local delete where a remote file has been removed, but I don't think
* we will need that.
*/
use FtpSync\FtpSync;
use FtpSync\File;
use FtpSync\Ftp;
use FtpSync\Output;
use FtpSync\PhpExtensions;
// Load dependencies (avoiding Composer for now)
$projectRoot = realpath(__DIR__);
foreach (glob($projectRoot . '/src/*.php') as $classFile) {
require_once $classFile;
}
// If we are in web mode, permit a "dry run" parameter to be supplied
$options = [];
if (isset($_GET)) {
$options['web'] = true;
if (isset($_GET['dryrun'])) {
$options['dryrun'] = true;
}
}
$ftpSync = new FtpSync(
new File(),
new Ftp(),
new Output(),
new PhpExtensions(),
$projectRoot,
['config' => 'config.php', ],
$options
);
$ftpSync->run();