This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New SFTP plugin, working with phpseclib, added
- Loading branch information
1 parent
84f0ee1
commit c957db1
Showing
32 changed files
with
28,418 additions
and
0 deletions.
There are no files selected for viewing
847 changes: 847 additions & 0 deletions
847
core/src/plugins/access.sftp_psl/SFTPPSL_StreamWrapper.php
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
core/src/plugins/access.sftp_psl/SFTP_StreamWrapper_LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2013 Warhawk3407 and other contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
25 changes: 25 additions & 0 deletions
25
core/src/plugins/access.sftp_psl/SFTP_StreamWrapper_README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# **SFTP_StreamWrapper** # | ||
for *PHP Secure Communications Library* (PHPSecLib) | ||
|
||
---------- | ||
|
||
#### Author: #### | ||
|
||
- Nikita ROUSSEAU | ||
|
||
#### Links: #### | ||
|
||
* [Browse SFTPStreamWrapper Git](https://github.com/warhawk3407/SFTP_StreamWrapper_PHPSecLib) | ||
* [PHPSecLib](http://phpseclib.sourceforge.net/) | ||
|
||
#### Description: #### | ||
|
||
> PHP 5.4.0 | ||
> This class implements a read/write SFTP stream wrapper based on 'phpseclib' | ||
- Requirement: phpseclib - PHP Secure Communications Library | ||
- Filename: SFTP_StreamWrapper.php | ||
- Classname: SFTP_StreamWrapper | ||
- Protocol: `sftp://` | ||
- Version: `Release: @1.1.0@` |
176 changes: 176 additions & 0 deletions
176
core/src/plugins/access.sftp_psl/class.sftpPSLAccessDriver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<?php | ||
/* | ||
* Copyright 2013 Nikita ROUSSEAU <warhawk3407@gmail.com> | ||
* This file is part of AjaXplorer. | ||
* | ||
* AjaXplorer is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* AjaXplorer is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with AjaXplorer. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* The latest code can be found at <http://www.ajaxplorer.info/>. | ||
* | ||
*/ | ||
defined('AJXP_EXEC') or die( 'Access not allowed' ); | ||
|
||
|
||
|
||
|
||
/** | ||
* AJXP_Plugin to access a remote server using SSH File Transfer Protocol (SFTP) with phpseclib ( http://phpseclib.sourceforge.net/ ) | ||
* | ||
* @author warhawk3407 <warhawk3407@gmail.com> | ||
* @author Charles du Jeu <contact (at) cdujeu.me> | ||
* @version Release: 1.0.1 | ||
*/ | ||
class sftpPSLAccessDriver extends fsAccessDriver | ||
{ | ||
|
||
/** | ||
* @var Repository | ||
*/ | ||
public $repository; | ||
public $driverConf; | ||
protected $wrapperClassName; | ||
protected $urlBase; | ||
|
||
/** | ||
* initRepository | ||
*/ | ||
function initRepository() { | ||
if(is_array($this->pluginConf)){ | ||
$this->driverConf = $this->pluginConf; | ||
}else{ | ||
$this->driverConf = array(); | ||
} | ||
|
||
ConfService::setConf("PROBE_REAL_SIZE", false); | ||
|
||
require_once($this->getBaseDir()."/SFTPPSL_StreamWrapper.php"); | ||
|
||
$create = $this->repository->getOption("CREATE"); | ||
$path = $this->repository->getOption("PATH"); | ||
|
||
$wrapperData = $this->detectStreamWrapper(true); | ||
$this->wrapperClassName = $wrapperData["classname"]; | ||
$this->urlBase = $wrapperData["protocol"]."://".$this->repository->getId(); | ||
// print "lol"; | ||
} | ||
|
||
function detectStreamWrapper($register = false) { | ||
if($register){ | ||
require_once($this->getBaseDir()."/SFTPPSL_StreamWrapper.php"); | ||
} | ||
return parent::detectStreamWrapper($register); | ||
} | ||
|
||
/** | ||
* Parse | ||
* @param DOMNode $contribNode | ||
*/ | ||
protected function parseSpecificContributions(&$contribNode){ | ||
parent::parseSpecificContributions($contribNode); | ||
if($contribNode->nodeName != "actions") return ; | ||
$this->disableArchiveBrowsingContributions($contribNode); | ||
} | ||
|
||
function filesystemFileSize($filePath){ | ||
$bytesize = filesize($filePath); | ||
if($bytesize < 0){ | ||
$bytesize = sprintf("%u", $bytesize); | ||
} | ||
return $bytesize; | ||
} | ||
|
||
/** | ||
* @param $src | ||
* @param $dest | ||
* @param $basedir | ||
* @return zipfile | ||
*/ | ||
function makeZip ($src, $dest, $basedir) | ||
{ | ||
@set_time_limit(60); | ||
require_once(AJXP_BIN_FOLDER."/pclzip.lib.php"); | ||
$filePaths = array(); | ||
|
||
$uniqid = uniqid(); | ||
$uniqfolder = '/tmp/ajaxplorer-zip-'.$uniqid; | ||
mkdir($uniqfolder); | ||
|
||
foreach ($src as $item){ | ||
$basedir = trim(dirname($item)); | ||
$basename = basename($item); | ||
$uniqpath = $uniqfolder.'/'.$basename; | ||
$this->full_copy($this->urlBase.$item, $uniqpath); | ||
$filePaths[] = array(PCLZIP_ATT_FILE_NAME => $uniqpath, | ||
PCLZIP_ATT_FILE_NEW_SHORT_NAME => $basename); | ||
} | ||
AJXP_Logger::debug("Pathes", $filePaths); | ||
AJXP_Logger::debug("Basedir", array($basedir)); | ||
$archive = new PclZip($dest); | ||
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $uniqfolder, PCLZIP_OPT_NO_COMPRESSION); | ||
$this->recursiveRmdir($uniqfolder); | ||
if(!$vList){ | ||
throw new Exception("Zip creation error : ($dest) ".$archive->errorInfo(true)); | ||
} | ||
return $vList; | ||
} | ||
|
||
function full_copy( $source, $destination ) { | ||
if ( is_dir( $source ) ) { | ||
@mkdir( $destination ); | ||
$directory = dir( $source ); | ||
while ( FALSE !== ( $readdirectory = $directory->read() ) ) { | ||
if ( $readdirectory == '.' || $readdirectory == '..' ) { | ||
continue; | ||
} | ||
$PathDir = $source . '/' . $readdirectory; | ||
if ( is_dir( $PathDir ) ) { | ||
$this->full_copy( $PathDir, $destination . '/' . $readdirectory ); | ||
continue; | ||
} | ||
copy( $PathDir, $destination . '/' . $readdirectory ); | ||
} | ||
|
||
$directory->close(); | ||
}else { | ||
copy( $source, $destination ); | ||
} | ||
} | ||
|
||
function recursiveRmdir($path) | ||
{ | ||
if (is_dir($path)) | ||
{ | ||
$path = rtrim($path, '/'); | ||
$subdir = dir($path); | ||
while (($file = $subdir->read()) !== false) | ||
{ | ||
if ($file != '.' && $file != '..') | ||
{ | ||
(!is_link("$path/$file") && is_dir("$path/$file")) ? $this->recursiveRmdir("$path/$file") : unlink("$path/$file"); | ||
} | ||
} | ||
$subdir->close(); | ||
rmdir($path); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function isWriteable($dir, $type="dir") | ||
{ | ||
return is_writable($dir); | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.