38 $host = preg_replace(
'#' . preg_quote($parsed[
'path']) .
'(/)?$#',
'', $url);
39 $path = (isset($parsed[
'path'])) ? $parsed[
'path'] :
'/';
41 if (static::$handle) {
42 curl_reset(static::$handle);
43 $this->
curlSet(CURLOPT_URL, ($hostOnly) ? $host : $url);
45 static::$handle = ($hostOnly) ? curl_init($host) : curl_init($url);
48 if (!static::$handle) {
49 trigger_error(
'Could not initialize cURL.', E_USER_ERROR);
52 $username = $parsed[
'user'];
53 $password = (isset($parsed[
'pass'])) ? $parsed[
'pass'] :
'';
56 CURLOPT_USERPWD => $username .
':' . $password,
57 CURLOPT_RETURNTRANSFER =>
true,
58 CURLOPT_PORT => (isset($parsed[
'port'])) ? $parsed[
'port'] : 21,
59 CURLOPT_FOLLOWLOCATION =>
true,
63 if ($parsed[
'scheme'] ==
"ftps") {
65 CURLOPT_FTP_SSL => CURLFTPSSL_TRY,
66 CURLOPT_FTPSSLAUTH => CURLFTPAUTH_DEFAULT,
71 $options[CURLOPT_TIMEOUT] = $this->
getParameter(
'timeout');
76 CURLOPT_SSL_VERIFYPEER =>
true,
77 CURLOPT_SSL_VERIFYHOST => 2,
84 $options[CURLOPT_FTPPORT] =
'-';
87 foreach ($options as $option => $value) {
88 $this->
curlSet($option, $value);
105 $result = curl_exec(static::$handle);
111 $this->
curlSet(CURLOPT_SSL_VERIFYPEER,
false);
112 $this->
curlSet(CURLOPT_SSL_VERIFYHOST,
false);
114 $result = curl_exec(static::$handle);
119 && curl_errno(static::$handle) !== 9
120 && curl_errno(static::$handle) !== 21
122 trigger_error(curl_error(static::$handle), E_USER_ERROR);
336 $list = explode(PHP_EOL, trim($ls));
339 foreach ($list as $line) {
341 $split = preg_split(
'/\s+/', $line);
343 $info[
'type'] = $split[0][0];
344 $info[
'permissions'] = substr(array_shift($split),1);
345 $info[
'hardlinks'] = array_shift($split);
346 $info[
'user'] = array_shift($split);
347 $info[
'group'] = array_shift($split);
348 $info[
'size'] = array_shift($split);
349 $name = implode(
' ', array_splice($split, 3));
350 $info[
'mtime'] = strtotime(implode(
' ', $split));
352 $nodes[$name] = $info;