Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VD:SFTP] Make compatible with phpseclib version 2 or 3 when returned from connectCallback($options) #3687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions php/elFinderVolumeSFTPphpseclib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
**/
class elFinderVolumeSFTPphpseclib extends elFinderVolumeFTP {

/**
* Simple hack that could break for quick compatibility with phpseclib version 1-3
* Same value substitue for reference NET_SFTP_LOCAL_FILE and SFTP::SOURCE_LOCAL_FILE
*/
const NET_SFTP_LOCAL_FILE = 1;

/**
* Constructor
* Extend options with required fields
Expand Down Expand Up @@ -237,6 +243,10 @@ protected function parseRaw($info, $base, $nameOnly = false)
}

$name = $info['filename'];
//for compatability with phpseclib version 2/3
if (empty($info['permissions'])) {
$info['permissions'] = $info['mode'];
}

if ($info['type'] === 3) {
// check recursive processing
Expand Down Expand Up @@ -307,7 +317,7 @@ protected function parseRaw($info, $base, $nameOnly = false)
protected function parsePermissions($permissions, $isowner = true)
{
$permissions = decoct($permissions);
$perm = $isowner ? decbin($permissions[-3]) : decbin($permissions[-1]);
$perm = $isowner ? decbin((int)$permissions[-3]) : decbin((int)$permissions[-1]);

return array(
'read' => $perm[-3],
Expand Down Expand Up @@ -612,7 +622,7 @@ protected function _mkfile($path, $name)
if ($this->tmp) {
$path = $this->_joinPath($path, $name);
$local = $this->getTempFile();
$res = touch($local) && $this->connect->put($path, $local, NET_SFTP_LOCAL_FILE);
$res = touch($local) && $this->connect->put($path, $local, self::NET_SFTP_LOCAL_FILE);
unlink($local);
return $res ? $path : false;
}
Expand Down Expand Up @@ -640,7 +650,7 @@ protected function _copy($source, $targetDir, $name)
$local = $this->getTempFile();

if ($this->connect->get($source, $local)
&& $this->connect->put($target, $local, NET_SFTP_LOCAL_FILE)) {
&& $this->connect->put($target, $local, self::NET_SFTP_LOCAL_FILE)) {
$res = true;
}
unlink($local);
Expand Down
Loading