API16

JFilesystemHelper/ftpChmod

From Joomla! Documentation

< API16:JFilesystemHelper
Revision as of 17:36, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Quick FTP chmod http://www.php.net/manual/en/function.ftp-chmod.php <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JFilesystemHe...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Quick FTP chmod http://www.php.net/manual/en/function.ftp-chmod.php


[Edit Descripton]

Template:Description:JFilesystemHelper/ftpChmod

Syntax[edit]

ftpChmod($url, $mode)
Parameter Name Default Value Description
$url
$mode

Defined in[edit]

libraries/joomla/filesystem/helper.php

Importing[edit]

jimport( 'joomla.filesystem.helper' );

Source Body[edit]

function ftpChmod($url, $mode) {
        $sch = parse_url($url, PHP_URL_SCHEME);
        if (($sch != "ftp") && ($sch != "ftps")) {
                return false;
        }
        $server = parse_url($url, PHP_URL_HOST);
        $port = parse_url($url, PHP_URL_PORT);
        $path = parse_url($url, PHP_URL_PATH);
        $user = parse_url($url, PHP_URL_USER);
        $pass = parse_url($url, PHP_URL_PASS);
        if ((!$server) || (!$path)) { return false; }
        if (!$port) { $port = 21; }
        if (!$user) { $user = "anonymous"; }
        if (!$pass) { $pass = ""; }
        switch ($sch) {
                case "ftp":
                        $ftpid = ftp_connect($server, $port);
                        break;
                case "ftps":
                        $ftpid = ftp_ssl_connect($server, $port);
                        break;
        }
        if (!$ftpid) { return false; }
        $login = ftp_login($ftpid, $user, $pass);
        if (!$login) { return false; }
        $res = ftp_chmod($ftpid, $mode, $path);
        ftp_close($ftpid);
        return $res;
}

[Edit See Also] Template:SeeAlso:JFilesystemHelper/ftpChmod

Examples[edit]

<CodeExamplesForm />