157 | | if ( ! $recursive || ! $this->is_dir($file) ) { |
158 | | if ( ! function_exists('ftp_chmod') ) |
159 | | return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
160 | | return @ftp_chmod($this->link, $mode, $file); |
| 157 | if ( $recursive && $this->is_dir($file) ) { |
| 158 | //fetch contents of the directory |
| 159 | $filelist = $this->dirlist($file); |
| 160 | //make sure the directory isn't empty by testing for the presence of a returned array |
| 161 | if( is_array($filelist) ) { |
| 162 | foreach ( $filelist as $filename=>$metadata ) { |
| 163 | $this->chmod($file . '/' . $filename, $mode, $recursive); |
| 164 | } |
| 165 | } |
162 | | //Is a directory, and we want recursive |
163 | | $filelist = $this->dirlist($file); |
164 | | foreach ( $filelist as $filename ) { |
165 | | $this->chmod($file . '/' . $filename, $mode, $recursive); |
166 | | } |
167 | | return true; |
| 167 | //chmod the file or directory |
| 168 | if ( ! function_exists('ftp_chmod') ) |
| 169 | return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
| 170 | return @ftp_chmod($this->link, $mode, $file); |