summaryrefslogtreecommitdiff
path: root/includes/filetransfer
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-15 21:19:31 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-15 21:19:31 +0000
commit6abcc47e25e936aea84c2f1e287bc5e1a045fff4 (patch)
tree800c3c256246f6c0399b9f3ec89d8a8aa83f5005 /includes/filetransfer
parent945fd9e269fd1ddee861a079660862c56ee54f74 (diff)
downloadbrdo-6abcc47e25e936aea84c2f1e287bc5e1a045fff4.tar.gz
brdo-6abcc47e25e936aea84c2f1e287bc5e1a045fff4.tar.bz2
#538660 by JacobSingh, dww, JoshuaRogers, adrian, Crell, chx, anarcat, and cwgordon7: Add a functioning Plugin Manager to core. Can you say module installation and updates through the UI? I knew you could! :D
Diffstat (limited to 'includes/filetransfer')
-rw-r--r--includes/filetransfer/ftp.inc30
1 files changed, 21 insertions, 9 deletions
diff --git a/includes/filetransfer/ftp.inc b/includes/filetransfer/ftp.inc
index 32e02901a..48b745ab2 100644
--- a/includes/filetransfer/ftp.inc
+++ b/includes/filetransfer/ftp.inc
@@ -5,6 +5,15 @@
* Connection class using the FTP URL wrapper.
*/
class FileTransferFTPWrapper extends FileTransfer {
+
+ public function __construct($jail, $username, $password, $hostname, $port) {
+ $this->username = $username;
+ $this->password = $password;
+ $this->hostname = $hostname;
+ $this->port = $port;
+ parent::__construct($jail);
+ }
+
function connect() {
$this->connection = 'ftp://' . urlencode($this->username) . ':' . urlencode($this->password) . '@' . $this->hostname . ':' . $this->port . '/';
if (!is_dir($this->connection)) {
@@ -19,29 +28,29 @@ class FileTransferFTPWrapper extends FileTransfer {
}
function createDirectoryJailed($directory) {
- if (!@drupal_mkdir($directory)) {
+ if (!@drupal_mkdir($this->connection . $directory)) {
$exception = new FileTransferException('Cannot create directory @directory.', NULL, array('@directory' => $directory));
throw $exception;
}
}
function removeDirectoryJailed($directory) {
- if (is_dir($directory)) {
- $dh = opendir($directory);
+ if (is_dir($this->connection . $directory)) {
+ $dh = opendir($this->connection . $directory);
while (($resource = readdir($dh)) !== FALSE) {
if ($resource == '.' || $resource == '..') {
continue;
}
$full_path = $directory . DIRECTORY_SEPARATOR . $resource;
- if (is_file($full_path)) {
+ if (is_file($this->connection . $full_path)) {
$this->removeFile($full_path);
}
- elseif (is_dir($full_path)) {
+ elseif (is_dir($this->connection . $full_path)) {
$this->removeDirectory($full_path . '/');
}
}
closedir($dh);
- if (!rmdir($directory)) {
+ if (!rmdir($this->connection . $directory)) {
$exception = new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $directory));
throw $exception;
}
@@ -70,15 +79,18 @@ class FileTransferFTPWrapper extends FileTransfer {
}
/**
- * This is impossible with the stream wrapper,
- * So we cheat and use the other implementation
+ * This is impossible with the stream wrapper, so an exception is thrown.
+ *
+ * If the ftp extenstion is available, we will cheat and use it.
*
- * @staticvar FileTransferFTPExtension $ftp_ext_file_transfer
* @param string $path
* @param long $mode
* @param bool $recursive
*/
function chmodJailed($path, $mode, $recursive) {
+ if (!function_exists('ftp_connect')) {
+ throw new FileTransferException('Unable to set permissions on @path. Change umask settings on server to be world executable.', array('@path' => $path));
+ }
static $ftp_ext_file_transfer;
if (!$ftp_ext_file_transfer) {