コード例 #1
0
ファイル: curl_ftp.php プロジェクト: simpl/datapipe
function ftp_get_files_in_dir($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = $cmd;
    # merge opts
    $opts = merge_opts_for_output($pipe, $opts);
    # get local dir opt
    $local_dir = get_opt_config_value($prefix, $opts, 'local_dir');
    if (!check_opt_if_set_type($cmd, $local_dir, 'local_dir', 'string')) {
        return false;
    }
    # scan dir
    $res = ftp_scandir($opts, null, $cmd);
    if ($res === false) {
        return false;
    }
    # set the local dir
    $res['local_dir'] = $local_dir;
    # get files
    return ftp_get_files($res, $opts);
}
コード例 #2
0
ファイル: ftp.php プロジェクト: simpl/datapipe
function ftp_get_files_in_dir($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'ftp';
    # merge opts
    $opts = merge_opts($opts, $pipe, 'dir');
    # get execute opt
    $execute = get_opt_config_value($prefix, $opts, 'execute', true);
    if (!check_opt_set_type($cmd, $execute, 'execute', 'boolean')) {
        return false;
    }
    # check if we should execute or not
    if (!$execute) {
        return true;
    }
    # get dir opt
    $dir = get_opt($prefix, $opts, 'dir');
    if (!check_opt_set_type($cmd, $dir, 'dir', 'string')) {
        return false;
    }
    # get local dir opt
    $local_dir = get_opt($prefix, $opts, 'local_dir', $dir);
    if (!check_opt_set_type($cmd, $local_dir, 'local_dir', 'string')) {
        return false;
    }
    # setup connection
    $conn = ftp_get_conn($opts, $cmd);
    if (!$conn) {
        return false;
    }
    # clean and make dir
    if (!clean_dir($local_dir, $opts, $cmd)) {
        return false;
    }
    if (!make_dir($local_dir, $opts, $cmd)) {
        return false;
    }
    $opts['make_dir'] = false;
    # get list of files from remote server
    $files = ftp_scandir($opts, false, $cmd);
    if (!$files) {
        return false;
    }
    # build list of files
    $file_list = array();
    foreach ($files as $file_name) {
        $remote_file = "{$dir}/{$file_name}";
        $local_file = "{$local_dir}/{$file_name}";
        $file_list[] = array($remote_file, $local_file);
    }
    $opts['files'] = $file_list;
    # get all the files
    return ftp_get_files($opts, null, $cmd);
}