cvs: pear /Net_FTP/Net FTP.php
| From: | Tobias Schlitt | Date: | Tue, 16 Mar 2004 21:18:11 +0000 |
| Subject: | cvs: pear /Net_FTP/Net FTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-17468@lists.php.net to get a copy of this message | ||
toby Tue Mar 16 16:18:11 2004 EDT
Modified files:
/pear/Net_FTP/Net FTP.php
Log:
* Added patch by Ilja Polivanovas <ipa@assis.lt> to enable correct directory permissions.
http://cvs.php.net/diff.php/pear/Net_FTP/Net/FTP.php?r1=1.14&r2=1.15&ty=u
Index: pear/Net_FTP/Net/FTP.php
diff -u pear/Net_FTP/Net/FTP.php:1.14 pear/Net_FTP/Net/FTP.php:1.15
--- pear/Net_FTP/Net/FTP.php:1.14 Sun Mar 14 09:05:50 2004
+++ pear/Net_FTP/Net/FTP.php Tue Mar 16 16:18:10 2004
@@ -14,7 +14,7 @@
// | Authors: Tobias Schlitt <toby@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: FTP.php,v 1.14 2004/03/14 14:05:50 toby Exp $
+// $Id: FTP.php,v 1.15 2004/03/16 21:18:10 toby Exp $
require_once 'PEAR.php';
@@ -406,6 +406,12 @@
function chmodRecursive($target, $permissions)
{
+ static $dir_permissions;
+
+ if(!isset($dir_permissions)){ // Making directory specific permissions
+ $dir_permissions = $this->makeDirPermissions($permissions);
+ }
+
// If $target is an array: Loop through it
if (is_array($target)) {
@@ -421,7 +427,7 @@
$remote_path = $this->_construct_path($target);
// Chmod the directory itself
- $result = $this->chmod($remote_path, $permissions);
+ $result = $this->chmod($remote_path, $dir_permissions);
if (PEAR::isError($result)) {
return $result;
@@ -441,7 +447,7 @@
$remote_path_new = $remote_path.$dir_entry["name"]."/";
// Chmod the directory we're about to enter
- $result = $this->chmod($remote_path_new, $permissions);
+ $result = $this->chmod($remote_path_new, $dir_permissions);
if (PEAR::isError($result)) {
return $result;
@@ -478,6 +484,27 @@
} // end method chmodRecursive
/**
+ * This will return logical permissions mask for directory.
+ * if directory have to be writeable it have also be executable
+ *
+ * @access private
+ * @param string $permissions File permissions in digits for file (i.e. 666)
+ * @return string File permissions in digits for directory (i.e. 777)
+ */
+ function makeDirPermissions($permissions){
+ $permissions = (string)$permissions;
+
+ for($i = 0; $i < strlen($permissions); $i++){ // going through (user, group, world)
+ if((int)$permissions{$i} & 4 and !((int)$permissions{$i} & 1)){ // Read
permission is set
+ // but execute not yet
+ (int)$permissions{$i} = (int)$permissions{$i} + 1; // Adding execute flag
+ }
+ }
+
+ return (string)$permissions;
+ }
+
+ /**
* This will return the last modification-time of a file. You can either give this
* function a relative or an absolute path to the file to check.
* NOTE: Some servers will not support this feature and the function works