コード例 #1
0
/**
* FTP File to Location
*/
function ftp_file($source_file, $dest_file, $mimetype, $disable_error_mode = false)
{
    global $config, $lang, $error, $error_msg;
    $conn_id = attach_init_ftp();
    // Binary or Ascii ?
    $mode = FTP_BINARY;
    if (preg_match("/text/i", $mimetype) || preg_match("/html/i", $mimetype)) {
        $mode = FTP_ASCII;
    }
    $res = @ftp_put($conn_id, $dest_file, $source_file, $mode);
    if (!$res && !$disable_error_mode) {
        $error = true;
        if (!empty($error_msg)) {
            $error_msg .= '<br />';
        }
        $error_msg = sprintf($lang['Ftp_error_upload'], $config['ftp_path']) . '<br />';
        @ftp_quit($conn_id);
        return false;
    }
    if (!$res) {
        return false;
    }
    @ftp_site($conn_id, 'CHMOD 0644 ' . $dest_file);
    @ftp_quit($conn_id);
    return true;
}
コード例 #2
0
ファイル: TpDebug.php プロジェクト: JeffersonFSilva/turbophp
function TpDbgSend($inMsg)
{
    global $TpDbg;
    if ($inMsg != '') {
        @ftp_site($TpDbg, $inMsg);
    }
}
コード例 #3
0
ファイル: ftp.php プロジェクト: sovcn/Sovereign-Clan-Manager
 function upload($file, $filename)
 {
     $this->connect();
     $this->dir = FTP_DIR . $filename;
     $upload = ftp_put($this->conid, $this->dir, $file, FTP_BINARY);
     $ch = ftp_site($this->conid, "chmod 777 " . $this->dir);
     $this->disconnect();
 }
コード例 #4
0
ファイル: file.helper.php プロジェクト: ahmatjan/cmf2
 function FtpMkdir($truepath, $mmode, $isMkdir = true)
 {
     global $cfg_basedir, $cfg_ftp_root, $g_ftpLink;
     OpenFtp();
     $ftproot = preg_replace('/' . $cfg_ftp_root . '$/', '', $cfg_basedir);
     $mdir = preg_replace('/^' . $ftproot . '/', '', $truepath);
     if ($isMkdir) {
         ftp_mkdir($g_ftpLink, $mdir);
     }
     return ftp_site($g_ftpLink, "chmod {$mmode} {$mdir}");
 }
コード例 #5
0
 function ftp_chmod($ftpstream, $chmod, $file)
 {
     $old = error_reporting();
     //save old
     error_reporting(0);
     //set to none
     $result = ftp_site($ftpstream, "CHMOD " . intval($chmod, 8) . " " . $file);
     error_reporting($old);
     //reset to old
     return $result;
     //will result TRUE or FALSE
 }
コード例 #6
0
ファイル: Ftp.php プロジェクト: ssrsfs/blg
 public function chmod($mode, $file)
 {
     if ($this->_ftpStream) {
         if (function_exists('ftp_chmod')) {
             return ftp_chmod($this->_ftpStream, $mode, $file);
         } else {
             //echo "<h1>$file</h1>";
             return ftp_site($this->_ftpStream, "chmod {$mode} {$file}");
             //return ftp_exec($this->ftpStream, "chmod $mode $file");
         }
     }
     return false;
 }
コード例 #7
0
ファイル: filesystem.php プロジェクト: l1ght13aby/Ubilling
function rcms_ftp_mkdir($dir, $server, $username, $password, $path)
{
    if (!is_dir(dirname($dir))) {
        rcms_ftp_mkdir(dirname($dir));
    }
    $ftp = ftp_connect($server);
    ftp_login($ftp, $username, $password);
    if (RCMS_ROOT_PATH == '../') {
        $path .= 'admin/';
    }
    ftp_mkdir($ftp, $path . $dir);
    ftp_site($ftp, 'CHMOD 0777 ' . $path . $dir);
    ftp_close($ftp);
    return true;
}
コード例 #8
0
ファイル: fileop.class.php プロジェクト: babae/etano
 function set_permission($file, $mode)
 {
     $myreturn = '';
     if ($this->op_mode == 'disk') {
         $myreturn = @chmod($file, $mode);
     } elseif ($this->op_mode == 'ftp') {
         $file = str_replace(_BASEPATH_ . '/', _FTPPATH_, $file);
         $old_de = ini_get('display_errors');
         ini_set('display_errors', 0);
         if (function_exists('ftp_chmod')) {
             $myreturn = @ftp_chmod($this->ftp_id, $mode, $file);
         } else {
             $myreturn = ftp_site($this->ftp_id, "CHMOD {$mode} {$file}");
         }
         ini_set('display_errors', $old_de);
     }
 }
コード例 #9
0
ファイル: function_server.php プロジェクト: humor-zo/chaofan
function upload_video($flv, $ip, $username, $password, $ftp_root)
{
    $conn_id = ftp_connect($ip);
    $ftp_login = ftp_login($conn_id, $username, $password);
    if (!$conn_id or !$ftp_login) {
        die('Failed to connect to FTP server!');
    }
    ftp_pasv($conn_id, 1);
    if (!ftp_chdir($conn_id, $ftp_root)) {
        die('Failed to change directory to: ' . $ftp_root);
    }
    if (file_exists($flv)) {
        $filename = basename($flv);
        ftp_delete($conn_id, $filename);
        ftp_put($conn_id, $filename, $flv, FTP_BINARY);
        ftp_site($conn_id, sprintf('CHMOD %u %s', 777, $filename));
    }
    ftp_close($conn_id);
}
コード例 #10
0
ファイル: ftp.php プロジェクト: Nolfneo/docvert
function copyFileViaFtp($sourcePath, $destinationPath, $connectionId)
{
    $errorMessage = '';
    $sourcePath = str_replace(" ", "-", $sourcePath);
    $destinationPath = sanitiseFtpPath($destinationPath);
    if (@(!ftp_mkdir($connectionId, $destinationPath))) {
        $errorMessage .= "&error-ftp-unable-to-create-directory; " . $destinationPath . "\n";
    }
    @ftp_site($connectionId, 'CHMOD 0777 ' . $destinationPath);
    // non-Unix-based servers may respond with "Command not implemented for that parameter" as they don't support chmod, so don't display any errors of this command.
    ftp_chdir($connectionId, $destinationPath);
    //print $sourcePath.' to '.$destinationPath."<br />";
    if (is_dir($sourcePath)) {
        chdir($sourcePath);
        $handle = opendir('.');
        while (($file = readdir($handle)) !== false) {
            if ($file != "." && $file != "..") {
                if (is_dir($file)) {
                    $errorMessage .= copyFileViaFtp($sourcePath . DIRECTORY_SEPARATOR . $file, $file, $connectionId);
                    chdir($sourcePath);
                    if (!ftp_cdup($connectionId)) {
                        $errorMessage .= '&error-unable-ftp-cd-up;';
                    }
                } else {
                    if (substr($file, strlen($file) - 4, 4) != '.zip') {
                        $fp = fopen($file, 'r');
                        if (!ftp_fput($connectionId, sanitiseFtpPath($file), $fp, FTP_BINARY)) {
                            $errorMessage .= '&error-unable-ftp-fput;';
                        }
                        @ftp_site($connectionId, 'CHMOD 0755 ' . sanitiseFtpPath($file));
                        fclose($fp);
                    }
                }
            }
        }
        closedir($handle);
    }
    return $errorMessage;
}
コード例 #11
0
ファイル: fups.class.php プロジェクト: piotrkabacinski/fups
 function connect()
 {
     if (file_exists(__DIR__ . "/../fups_connects/" . sha1($this->location) . ".json")) {
         $fups = json_decode(file_get_contents(__DIR__ . "/../fups_connects/" . sha1($this->location) . ".json"), true);
         $this->host = $fups['connection']['host'];
         $this->login = $fups['connection']['login'];
         $this->password = $fups['connection']['password'];
         $this->dir = $fups['dir'];
         $this->port = $fups['connection']['port'];
         $connection = ftp_connect($this->host, $this->port) or die($this->red . "Cannot connect to host" . $this->messageEnd);
         ftp_login($connection, $this->login, $this->password) or die($this->red . "Cannot login" . $this->messageEnd);
         if (ftp_site($connection, sprintf('CHMOD %o %s', 0777, $this->dir))) {
             $this->connection = $connection;
         } else {
             echo $this->red . "No " . $this->dir . " @ " . $this->host . $this->messageEnd;
             exit;
         }
     } else {
         echo $this->red . "No fups connection file for " . $this->location . $this->messageEnd;
         exit;
     }
     return;
 }
コード例 #12
0
ファイル: install.php プロジェクト: Bouhnosaure/Typesetter
 /**
  * Restore the mode of the root directory to it's original mode
  *
  */
 public function FTP_RestoreMode()
 {
     global $install_ftp_connection, $langmessage;
     if (!$this->root_mode || !$install_ftp_connection) {
         return;
     }
     $mode = $this->root_mode & 0777;
     $mode = '0' . decoct($mode);
     $ftp_cmd = 'CHMOD ' . $mode . ' ' . $this->ftp_root;
     if (!ftp_site($install_ftp_connection, $ftp_cmd)) {
         echo '<li><span class="failed">';
         echo sprintf($langmessage['Could_Not_'], '<em>Restore mode for ' . $this->ftp_root . ': ' . $ftp_cmd . '</em>');
         echo '</span></li>';
         return;
     }
 }
コード例 #13
0
ファイル: ftp.php プロジェクト: akksi/jcg
 /**
  * Method to restart data transfer at a given byte
  *
  * @access public
  * @param int $point Byte to restart transfer at
  * @return boolean True if successful
  */
 function restart($point)
 {
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         if (@ftp_site($this->_conn, 'REST ' . $point) === false) {
             JError::raiseWarning('35', JText::_('JLIB_CLIENT_ERROR_JFTP_RESTART_BAD_RESPONSE_NATIVE'));
             return false;
         }
         return true;
     }
     // Send restart command and verify success
     if (!$this->_putCmd('REST ' . $point, 350)) {
         JError::raiseWarning('35', JText::sprintf('JLIB_CLIENT_ERROR_JFTP_RESTART_BAD_RESPONSE', $this->_response, $point));
         return false;
     }
     return true;
 }
コード例 #14
0
ファイル: FtpDriver.php プロジェクト: komaspieler/yii2-gftp
 /**
  * Sends a SITE command request to the FTP server.
  *
  * @param string    $command       FTP command (does not include <strong>SITE</strong> word).
  *
  * @throws FtpException If command execution fails.
  */
 public function site($command)
 {
     $this->connectIfNeeded();
     $this->param = "SITE " . $command;
     if (!ftp_site($this->handle, $command)) {
         throw new FtpException(Yii::t('gftp', 'Could not execute command "{command}" on "{host}"', ['host' => $this->host, '{command}' => $this->param]));
     }
 }
コード例 #15
0
ファイル: Ftp.php プロジェクト: robeendey/ce
 public function site($command)
 {
     $ret = @ftp_site($this->getResource(), $command);
     if (!$ret) {
         throw new Engine_Vfs_Adapter_Exception(sprintf('Unable to execute SITE command: %s', $command));
     }
     return $ret;
 }
コード例 #16
0
ファイル: _ftps.php プロジェクト: Hezkibel/soft
 function chmod($pathname, $mode)
 {
     return @ftp_site($this->ftp_conn, sprintf('CHMOD %o %s', $mode, $pathname));
 }
コード例 #17
0
ファイル: discuz_ftp.php プロジェクト: softhui/discuz
 function ftp_chmod($filename, $mod = 0777)
 {
     $filename = discuz_ftp::clear($filename);
     if (function_exists('ftp_chmod')) {
         return @ftp_chmod($this->connectid, $mod, $filename);
     } else {
         return @ftp_site($this->connectid, 'CHMOD ' . $mod . ' ' . $filename);
     }
 }
コード例 #18
0
ファイル: ftp.php プロジェクト: joebushi/joomla
 /**
  * Method to restart data transfer at a given byte
  *
  * @access public
  * @param int $point Byte to restart transfer at
  * @return boolean True if successful
  */
 function restart($point)
 {
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         if (@ftp_site($this->_conn, 'REST ' . $point) === false) {
             JError::raiseWarning('35', 'JFTP::restart: Bad response');
             return false;
         }
         return true;
     }
     // Send restart command and verify success
     if (!$this->_putCmd('REST ' . $point, 350)) {
         JError::raiseWarning('35', 'JFTP::restart: Bad response', 'Server response: ' . $this->_response . ' [Expected: 350] Restart point sent: ' . $point);
         return false;
     }
     return true;
 }
コード例 #19
0
function FtpMkdir($truepath,$mmode,$isMkdir=true){
	global $cfg_basedir,$cfg_ftp_root,$g_ftpLink;
	OpenFtp();
	$ftproot = ereg_replace($cfg_ftp_root.'$','',$cfg_basedir);
	$mdir = ereg_replace('^'.$ftproot,'',$truepath);
	if($isMkdir) ftp_mkdir($g_ftpLink,$mdir);
	return ftp_site($g_ftpLink,"chmod $mmode $mdir");
}
コード例 #20
0
ファイル: function_ftp.php プロジェクト: NaturalWill/UCQA
function sftp_site($ftp_stream, $cmd)
{
    $cmd = wipespecial($cmd);
    return @ftp_site($ftp_stream, $cmd);
}
コード例 #21
0
ファイル: fn.fs.php プロジェクト: heg-arc-ne/cscart
function fn_ftp_chmod_file($filename, $perm = DEFAULT_FILE_PERMISSIONS, $recursive = false)
{
    $result = false;
    $ftp = Registry::get('ftp_connection');
    if (is_resource($ftp)) {
        $dest = dirname($filename);
        $dest = rtrim($dest, '/') . '/';
        // force adding trailing slash to path
        $rel_path = str_replace(Registry::get('config.dir.root') . '/', '', $dest);
        $cdir = ftp_pwd($ftp);
        if (empty($rel_path)) {
            // if rel_path is empty, assume it's root directory
            $rel_path = $cdir;
        }
        if (@ftp_chdir($ftp, $rel_path)) {
            $result = @ftp_site($ftp, 'CHMOD ' . sprintf('0%o', $perm) . ' ' . fn_basename($filename));
            if ($recursive) {
                $path = fn_normalize_path($cdir . '/' . $rel_path . fn_basename($filename));
                if (is_dir($path)) {
                    $_files = fn_get_dir_contents($path, true, true, '', '', true);
                    if (!empty($_files)) {
                        foreach ($_files as $_file) {
                            fn_ftp_chmod_file($path . '/' . $_file, $perm, false);
                        }
                    }
                }
            }
            ftp_chdir($ftp, $cdir);
        }
    }
    return $result;
}
コード例 #22
0
ファイル: ftp.php プロジェクト: luozhanhong/share
 /**
  *
  * 向服务器发送 SITE 命令
  *
  * @param string $command
  * @return bool
  */
 public static function site($command)
 {
     return ftp_site(self::$resource, $command);
 }
コード例 #23
0
 /**
  * FTP SITE command (ftp-only function)
  * @access private
  */
 function _site($command)
 {
     return @ftp_site($this->connection, $command);
 }
コード例 #24
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function upload(&$out)
 {
     set_time_limit(0);
     global $restore;
     global $file;
     global $file_name;
     global $folder;
     if (!$folder) {
         if (substr(php_uname(), 0, 7) == "Windows") {
             $folder = '/.';
         } else {
             $folder = '/';
         }
     } else {
         $folder = '/' . $folder;
     }
     if ($restore != '') {
         //$file=ROOT.'saverestore/'.$restore;
         $file = $restore;
     } elseif ($file != '') {
         copy($file, ROOT . 'saverestore/' . $file_name);
         //$file=ROOT.'saverestore/'.$file_name;
         $file = $file_name;
     }
     umask(0);
     @mkdir(ROOT . 'saverestore/temp', 0777);
     if ($file != '') {
         // && mkdir(ROOT.'saverestore/temp', 0777)
         chdir(ROOT . 'saverestore/temp');
         if (substr(php_uname(), 0, 7) == "Windows") {
             // for windows only
             exec(DOC_ROOT . '/gunzip ../' . $file, $output, $res);
             exec(DOC_ROOT . '/tar xvf ../' . str_replace('.tgz', '.tar', $file), $output, $res);
             //@unlink('../'.str_replace('.tgz', '.tar', $file));
         } else {
             exec('tar xzvf ../' . $file, $output, $res);
         }
         @unlink(ROOT . 'saverestore/temp' . $folder . '/config.php');
         //print_r($output);exit;
         if (1) {
             chdir('../../');
             if ($this->method == 'direct') {
                 // UPDATING FILES DIRECTLY
                 $this->copyTree(ROOT . 'saverestore/temp' . $folder, ROOT, 1);
                 // restore all files
             } elseif ($this->method == 'ftp') {
                 // UPDATING FILES BY FTP
                 $conn_id = @ftp_connect($this->config['FTP_HOST']);
                 if ($conn_id) {
                     $login_result = @ftp_login($conn_id, $this->config['FTP_USERNAME'], $this->config['FTP_PASSWORD']);
                     if ($login_result) {
                         $systyp = ftp_systype($conn_id);
                         if (@ftp_chdir($conn_id, $this->config['FTP_FOLDER'] . 'saverestore')) {
                             @ftp_chdir($conn_id, $this->config['FTP_FOLDER']);
                             // ok, we're in. updating!
                             $log = '';
                             $files = $this->getLocalFilesTree(ROOT . 'saverestore/temp' . $folder, '.+', 'installed', $log, 0);
                             $total = count($files);
                             $modules_processed = array();
                             for ($i = 0; $i < $total; $i++) {
                                 $file = $files[$i];
                                 $file['REMOTE_FILENAME'] = preg_replace('/^' . preg_quote(ROOT . 'saverestore/temp/' . $folder, '/') . '/is', $this->config['FTP_FOLDER'], $file['FILENAME']);
                                 $file['REMOTE_FILENAME'] = str_replace('//', '/', $file['REMOTE_FILENAME']);
                                 $res_f = $this->ftpput($conn_id, $file['REMOTE_FILENAME'], $file['FILENAME'], FTP_BINARY);
                                 if (preg_match('/\\.class\\.php$/', basename($file['FILENAME'])) && !$modules_processed[dirname($file['REMOTE_FILENAME'])]) {
                                     // if this a module then we should update attributes for folder and remove 'installed' file
                                     $modules_processed[dirname($file['REMOTE_FILENAME'])] = 1;
                                     @ftp_site($conn_id, "CHMOD 0777 " . dirname($file['REMOTE_FILENAME']));
                                     @ftp_delete($conn_id, dirname($file['REMOTE_FILENAME']) . '/installed');
                                 }
                             }
                         } else {
                             $out['FTP_ERR'] = 'Incorrect folder (' . $ftp_folder . ')';
                         }
                     } else {
                         $out['FTP_ERR'] = 'Incorrect username/password';
                     }
                     ftp_close($conn_id);
                 } else {
                     $out['FTP_ERR'] = 'Cannot connect to host (' . $ftp_host . ')';
                     $this->redirect("?err_msg=" . urlencode($out['FTP_ERR']));
                 }
             }
             //if (is_dir(ROOT.'saverestore/temp/'.$folder.'modules')) {
             // code restore
             $source = ROOT . 'modules';
             if ($dir = @opendir($source)) {
                 while (($file = readdir($dir)) !== false) {
                     if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..') {
                         // && !file_exists($source."/".$file."/installed")
                         @unlink(ROOT . "modules/" . $file . "/installed");
                     }
                 }
             }
             @unlink(ROOT . "modules/control_modules/installed");
             @SaveFile(ROOT . 'reboot', 'updated');
             //}
             if (file_exists(ROOT . 'saverestore/temp' . $folder . '/dump.sql')) {
                 // data restore
                 $this->restoredatabase(ROOT . 'saverestore/temp' . $folder . '/dump.sql');
             }
             $this->config['LATEST_UPDATED_ID'] = $out['LATEST_ID'];
             $this->saveConfig();
             $this->redirect("?mode=clear&ok_msg=" . urlencode("Updates Installed!"));
         }
     }
     /*
          require 'Tar.php';
          $tar_object = new Archive_Tar($file);
          if ($tar_object->extract(ROOT.'skins/'.$basename)) {
           $out['OK_EXT']=1;
          } else {
           $out['ERR_FORMAT']=1;
          }
     */
 }
コード例 #25
0
 /**
  * @param string $file
  * @param int $mode
  * @param bool $recursive
  * @return bool
  */
 public function chmod($file, $mode = false, $recursive = false)
 {
     if (!$mode) {
         if ($this->is_file($file)) {
             $mode = FS_CHMOD_FILE;
         } elseif ($this->is_dir($file)) {
             $mode = FS_CHMOD_DIR;
         } else {
             return false;
         }
     }
     // chmod any sub-objects if recursive.
     if ($recursive && $this->is_dir($file)) {
         $filelist = $this->dirlist($file);
         foreach ((array) $filelist as $filename => $filemeta) {
             $this->chmod($file . '/' . $filename, $mode, $recursive);
         }
     }
     // chmod the file or directory
     if (!function_exists('ftp_chmod')) {
         return (bool) @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
     }
     return (bool) @ftp_chmod($this->link, $mode, $file);
 }
コード例 #26
0
ファイル: FileSystem.php プロジェクト: andreyvit/retester
 function ftp_chmod($ftp, $mode, $file)
 {
     return @ftp_site($ftp, sprintf('CHMOD %o %s', $mode, $file));
 }
コード例 #27
0
function ftp_mysite($conn_id, $command)
{
    // --------------
    // This function sends a site command to the FTP server
    // Note:
    //    - These commands vary a lot depending on the FTP server type
    //    - PHP does not return any result other than TRUE or FALSE
    // --------------
    $success1 = ftp_site($conn_id, $command);
    if ($success1 == false) {
        $errormessage = __("Unable to execute site command <b>%1\$s</b>", $command);
        setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
}
コード例 #28
0
ファイル: autoinstall.lib.php プロジェクト: Gunmania/xe-core
 /**
  * Copy directory
  *
  * @param array $file_list File list to copy
  * @return Object
  */
 function _copyDir(&$file_list)
 {
     if (!$this->ftp_password) {
         return new Object(-1, 'msg_ftp_password_input');
     }
     $output = $this->_connect();
     if (!$output->toBool()) {
         return $output;
     }
     if (!$this->target_path) {
         $this->target_path = '.';
     }
     if (substr($this->download_path, -1) == '/') {
         $this->download_path = substr($this->download_path, 0, -1);
     }
     $target_dir = $this->ftp_info->ftp_root_path . $this->target_path;
     if (is_array($file_list)) {
         foreach ($file_list as $k => $file) {
             if (!$file) {
                 continue;
             }
             $org_file = $file;
             if ($this->package->path == ".") {
                 $file = substr($file, 3);
             }
             $path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
             $path_list = explode('/', dirname($this->target_path . "/" . $file));
             $real_path = "./";
             $ftp_path = $this->ftp_info->ftp_root_path;
             for ($i = 0; $i < count($path_list); $i++) {
                 if ($path_list == "") {
                     continue;
                 }
                 $real_path .= $path_list[$i] . "/";
                 $ftp_path .= $path_list[$i] . "/";
                 if (!file_exists(FileHandler::getRealPath($real_path))) {
                     if (!@ftp_mkdir($this->connection, $ftp_path)) {
                         return new Object(-1, "msg_make_directory_failed");
                     }
                     if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
                         if (function_exists('ftp_chmod')) {
                             if (!ftp_chmod($this->connection, 0755, $ftp_path)) {
                                 return new Object(-1, "msg_permission_adjust_failed");
                             }
                         } else {
                             if (!ftp_site($this->connection, "CHMOD 755 " . $ftp_path)) {
                                 return new Object(-1, "msg_permission_adjust_failed");
                             }
                         }
                     }
                 }
             }
             if (!ftp_put($this->connection, $target_dir . '/' . $file, FileHandler::getRealPath($this->download_path . "/" . $org_file), FTP_BINARY)) {
                 return new Object(-1, "msg_ftp_upload_failed");
             }
         }
     }
     $this->_close();
     return new Object();
 }
コード例 #29
0
ファイル: functions.php プロジェクト: TlhanGhun/SiFiEx
 function ftp_chmod($ftp_stream, $mode, $filename)
 {
     // *************************************************
     // function ftp_chmod
     // Parameters:
     //   $ftp_stream: link to already opened FTP-connection
     //   $mode: which permissions to be set (e.g. 0755)
     //   $filename: file to change the permissions for
     // Return value: $value
     //
     // Changes permissions of a file using FTP
     // This function is part of PHP5 but not included in PHP4
     // so this is a backport to enable it in PHP4
     // *************************************************
     return @ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
 }
コード例 #30
0
ファイル: source_restore.php プロジェクト: arpad9/bygmarket
function fn_ftp_chmod_file($filename, $perm = DEFAULT_FILE_PERMISSIONS, $recursive = false)
{
    $result = false;
    $ftp = Registry::get('ftp_connection');
    if (is_resource($ftp)) {
        $dest = dirname($filename);
        $dest = rtrim($dest, '/') . '/';
        // force adding trailing slash to path
        $rel_path = str_replace(Registry::get('config.dir.root') . '/', '', $dest);
        $cdir = ftp_pwd($ftp);
        if (empty($rel_path)) {
            // if rel_path is empty, assume it's root directory
            $rel_path = $cdir;
        }
        if (@ftp_chdir($ftp, $rel_path)) {
            $result = @ftp_site($ftp, 'CHMOD ' . sprintf('0%o', $perm) . ' ' . basename($filename));
            ftp_chdir($ftp, $cdir);
        }
    }
    return $result;
}