Actions

API15

JFTP/chmod

From Joomla! Documentation

< API15:JFTP
Revision as of 12:20, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to change mode for a path on the FTP server

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

chmod($path, $mode)
Parameter Name Default Value Description
$path $path Path to change mode on
$mode $mode Octal value to change mode to, e.g. '0777', 0777 or 511

Returns

boolean True if successful

Defined in

libraries/joomla/client/ftp.php

Importing

jimport( 'joomla.client.ftp' );

Source Body

function chmod($path, $mode) {
 
        // If no filename is given, we assume the current directory is the target
        if ($path == '') {
                $path = '.';
        }
 
        // Convert the mode to a string
        if (is_int($mode)) {
                $mode = decoct($mode);
        }
 
        // If native FTP support is enabled lets use it...
        if (FTP_NATIVE) {
                if (@ftp_site($this->_conn, 'CHMOD '.$mode.' '.$path) === false) {
                        if($this->_OS != 'WIN') {
                                JError::raiseWarning('35', 'JFTP::chmod: Bad response' );
                        }
                        return false;
                }
                return true;
        }
 
        // Send change mode command and verify success [must convert mode from octal]
        if (!$this->_putCmd('SITE CHMOD '.$mode.' '.$path, array(200, 250))) {
                if($this->_OS != 'WIN') {
                        JError::raiseWarning('35', 'JFTP::chmod: Bad response', 'Server response: '.$this->_response.' [Expected: 200 or 250] Path sent: '.$path.' Mode sent: '.$mode);
                }
                return false;
        }
        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />