Пример #1
0
    private $remoteDir = false;
    private $regexpPattern = false;
    private $regexpReplacement = false;
    private $connection = false;
    private $connectionType = false;
    private $connectionPort = false;
    private $connectionTimeout = 10;
    private $arItems = array();
}
/* * ***************************************************************************** */
date_default_timezone_set('Europe/Moscow');
error_reporting(E_ERROR);
$config = ['indexFile' => 'files10.csv', 'typeconn' => FTP_INTERFACE, 'host' => 'demo.your-host.ru', 'user' => 'demo', 'password' => 'your-password', 'start_dir' => "www/demo.your-host.ru"];
$task = new Task();
$task->setLocalDir('temp');
$task->setRemoteDir($config['start_dir']);
$task->connect($config['host'], $config['user'], $config['password'], FTP_PORT, FTP_INTERFACE);
$task->setRegexp('|[\\s\\n\\r]+|', null);
if ($task->checkConnection()) {
    System::showMessage("\n\n * * *  Read the index file ({$config['indexFile']}) and downloadable files");
    $index = new LimitIterator(new SplFileObject($config["indexFile"]), 0, 1);
    while (!$index->eof()) {
        if ($remoteFile = $index->fgetcsv()[0]) {
            $localFile = $task->add($remoteFile);
        }
    }
    System::showMessage("\n\n * * *  Create backups and perform replacing in files");
    $task->replacement();
}
$task->disconnect();
/* * ***************************************************************************** */