function Joom_Chmod($dir, $mode = 0644) { static $ftpOptions; if(!isset($ftpOptions)) { // Initialize variables jimport('joomla.client.helper'); $ftpOptions = JClientHelper::getCredentials('ftp'); } if ($ftpOptions['enabled'] == 1) { //check if chmod is necessary, otherwise return true $fileperms= substr(decoct( fileperms($dir)),3); if ($fileperms >= decoct($mode)){ return true; } // Connect the FTP client jimport('joomla.client.ftp'); $ftp = &JFTP::getInstance( $ftpOptions['host'], $ftpOptions['port'], null, $ftpOptions['user'], $ftpOptions['pass'] ); // Translate path to FTP path $dir = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dir), '/'); $ftp->chmod($dir, $mode); } return true; }