protected function ftp_scan_dir($remote_directory, $targets = null)
{
$buff = ftp_rawlist($this->connect, $remote_directory);
$items = array();
if ($targets && is_array($targets)) {
$targets = array_flip($targets);
} else {
$targets = false;
}
foreach ($buff as $str) {
$info = preg_split("/\\s+/", $str, 9);
if (!isset($this->ftpOsUnix)) {
$this->ftpOsUnix = !preg_match('/\\d/', substr($info[0], 0, 1));
}
if (!$this->ftpOsUnix) {
$info = $this->normalizeRawWindows($str);
}
$type = substr($info[0], 0, 1);
$name = trim($info[8]);
if ($name !== '.' && $name !== '..' && (!$targets || isset($targets[$name]))) {
switch ($type) {
case 'l':
//omit symbolic links
//omit symbolic links
case 'd':
$remote_file_path = $this->_joinPath($remote_directory, $name);
$item = array();
$item['path'] = $remote_file_path;
$item['type'] = 'd';
// normal file
$items[] = $item;
$items = array_merge($items, $this->ftp_scan_dir($remote_file_path));
break;
default:
$remote_file_path = $this->_joinPath($remote_directory, $name);
$item = array();
$item['path'] = $remote_file_path;
$item['type'] = 'f';
// normal file
$items[] = $item;
}
}
}
return $items;
}