当前位置: 首页>>代码示例>>PHP>>正文


PHP ssh2_sftp_mkdir函数代码示例

本文整理汇总了PHP中ssh2_sftp_mkdir函数的典型用法代码示例。如果您正苦于以下问题:PHP ssh2_sftp_mkdir函数的具体用法?PHP ssh2_sftp_mkdir怎么用?PHP ssh2_sftp_mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ssh2_sftp_mkdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _save

 /**
  * Saves the image to the remote server. If the folder structure doesn't exist, create it.
  *
  * @param string $relFilename	path (with filename) from the CDN root
  * @param string $tempfile		temp file name to upload
  * @return bool
  */
 protected function _save($relFilename, $tempfile)
 {
     $base = Mage::getStoreConfig('imagecdn/ftp/base');
     $remotePath = str_replace('\\', '/', str_replace('//', '/', '/' . $base . '/' . $relFilename));
     ssh2_sftp_mkdir(ssh2_sftp($this->auth()), substr($remotePath, 0, strrpos($remotePath, '/')), 0777, true);
     $result = ssh2_scp_send($this->auth(), $tempfile, $remotePath, 0644);
     return $result ? true : false;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:15,代码来源:Sftp.php

示例2: sftp_store_file

 /**
  * sftp_store_file($fileContainer)
  * 
  * This function stores an image and its thumbnails to the right
  * SFTP accounts.
  *
  * @param image
  * @return nothing, for now
  */
 function sftp_store_file($fileContainer)
 {
     // adds the original url to the list of thumbs, as only this list of thumbnails is used to upload files
     if (isset($fileContainer->original_path) && strlen($fileContainer->original_path)) {
         $fileContainer->thumb_paths[] = $fileContainer->original_path;
     }
     // gets one or more servers where this image will be uploaded. The servers are selected based on different
     // factors and rules, which are configured in config.inc.php
     $servers = $this->get_target_servers($fileContainer);
     if (sizeof($servers) && sizeof($fileContainer->thumb_paths)) {
         $relative_path_to_store = dirname(reset($fileContainer->thumb_paths));
         //echo "rel: ".$relative_path_to_store."<br>\n";
         foreach ($servers as $server) {
             $conn_id = $this->get_sftp_connection_id($server);
             // this queries the open connections list for the right $conn_id.
             // If a connection to this server does not exist it will be created, then the connection id will be returned
             ssh2_sftp_mkdir($conn_id, $server['root_path'] . $relative_path_to_store, 0775, true);
             foreach ($fileContainer->thumb_paths as $local_file_path) {
                 $remote_filename = basename($local_file_path);
                 // gets only the filename from the path
                 if (!$this->sftp_put_file($conn_id, $server, $local_file_path, $server['root_path'] . $local_file_path)) {
                     echo "Couldn't upload file " . $local_file_path . "<br>\n";
                     return FALSE;
                     // TODO: Better error handling
                 }
             }
             // TODO: Check if all ids exist
             $sql_pic2server = "INSERT INTO {$this->config['TABLE_SFTP_PIC2SERVER']} SET pic_id='{$fileContainer->id}', server_id='{$server['id']}'";
             //echo "sql_pic2server: ".$sql_pic2server."<br>\n";
             cpg_db_query($sql_pic2server);
             $sql_quota = "UPDATE {$this->config['TABLE_SFTP_SERVERS']} SET used=used+{$fileContainer->total_filesize}, free=free-{$fileContainer->total_filesize} WHERE id='{$server['id']}'";
             //echo "sql_quota: ".$sql_quota."<br>\n";
             cpg_db_query($sql_quota);
             // TODO: Error handling
             // TODO: Rollback in case of errors
         }
         // foreach($fileContainer->thumb_paths as $fileContainer)
         // if $this->CONFIG['storage_sftp_keep_local_copy'] is set to false, delete the local files
         if (isset($this->config['storage_sftp_keep_local_copy']) && $this->config['storage_sftp_keep_local_copy'] == false) {
             if (sizeof($fileContainer->thumb_paths)) {
                 foreach ($fileContainer->thumb_paths as $local_file_path) {
                     if (is_file($local_file_path)) {
                         unlink($local_file_path);
                     }
                 }
             }
         }
     }
     // if(sizeof($servers) && sizeof($fileContainer->thumb_paths))// TODO: Else what? Error message?
 }
开发者ID:phill104,项目名称:branches,代码行数:59,代码来源:storage.php

示例3: sftp_walk

function sftp_walk($con, $sftp, $local_dir, $remote_dir)
{
    $dir = opendir($local_dir);
    ssh2_sftp_mkdir($sftp, $remote_dir, 0755, true);
    while (($file = readdir($dir)) !== false) {
        $local_file = $local_dir . '/' . $file;
        $remote_file = $remote_dir . '/' . $file;
        if (!is_dir($local_file)) {
            echo "Transferring {$local_file} to {$remote_file}\n";
            $scp_ret = ssh2_scp_send($con, $local_file, $remote_file, 0755);
            if (!$scp_ret) {
                fwrite(STDERR, "Failed to transfer {$local_file}.\n");
                exit(8);
            }
        } else {
            if ($file != "." && $file != "..") {
                sftp_walk($con, $sftp, $local_file, $remote_file);
            }
        }
    }
}
开发者ID:google-code-backups,项目名称:proveit-js,代码行数:21,代码来源:deploy.php

示例4: createDirectory

 /**
  * Creates a new directory.
  * @param string $path directory path to be created.
  * @return bool whether the directory is created successfully
  */
 protected function createDirectory($path)
 {
     $storage = $this->getStorage();
     $sftp = $storage->getSftp();
     if (file_exists($this->composeSftpPath($path))) {
         return true;
     }
     $parentPath = dirname($path);
     // recurse if parent dir does not exist and we are not at the root of the file system.
     if (!file_exists($this->composeSftpPath($parentPath)) && $parentPath !== $path) {
         $this->createDirectory($parentPath);
     }
     if (!ssh2_sftp_mkdir($sftp, $path, $storage->filePermission)) {
         return false;
     }
     return ssh2_sftp_chmod($sftp, $path, $storage->filePermission);
 }
开发者ID:yii2tech,项目名称:file-storage,代码行数:22,代码来源:Bucket.php

示例5: mkdir

 function mkdir($path, $chmod = false, $chown = false, $chgrp = false)
 {
     $path = $this->untrailingslashit($path);
     if (empty($path)) {
         return false;
     }
     if (!$chmod) {
         $chmod = FS_CHMOD_DIR;
     }
     if (!ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true)) {
         return false;
     }
     if ($chown) {
         $this->chown($path, $chown);
     }
     if ($chgrp) {
         $this->chgrp($path, $chgrp);
     }
     return true;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:20,代码来源:MFilesystemSsh2.php

示例6: copyFile

 /**
  * Copies a file to the remote system
  *
  * @param string $local
  * @param string $remote 
  */
 protected function copyFile($localEndpoint, $remoteEndpoint)
 {
     ssh2_sftp_mkdir($this->sftp, dirname($remoteEndpoint), 2775, true);
     $ret = ssh2_scp_send($this->connection, $localEndpoint, $remoteEndpoint);
     if ($ret === false) {
         throw new BuildException("Could not create remote file '" . $remoteEndpoint . "'");
     }
 }
开发者ID:rodneyway,项目名称:front-end-workflow-testing,代码行数:14,代码来源:SilverStripeDeployTask.php

示例7: mkdir

 /**
  * Remote mkdir.
  *
  * @param string $dirname
  * @param int    $mode
  * @param bool   $recursive
  *
  * @return bool
  */
 public function mkdir($dirname, $mode, $recursive = false)
 {
     return ssh2_sftp_mkdir($this->resource, $dirname, $mode, $recursive);
 }
开发者ID:moccalotto,项目名称:ssh,代码行数:13,代码来源:Sftp.php

示例8: mkdir

 /**
  * Create a directory in remote server
  */
 public function mkdir($dirName)
 {
     $dir = $this->dir . '/' . $dirName;
     if (!ssh2_sftp_mkdir($this->_getSftp(), $dir)) {
         throw new \Exception("Could not create directory '{$dir}'");
     }
     return true;
 }
开发者ID:banago,项目名称:bridge,代码行数:11,代码来源:Ssh2.php

示例9: mkdir

 function mkdir($path, $chmod = null, $chown = false, $chgrp = false)
 {
     $this->debug("mkdir();");
     $path = untrailingslashit($path);
     if (!ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true)) {
         return false;
     }
     if ($chown) {
         $this->chown($path, $chown);
     }
     if ($chgrp) {
         $this->chgrp($path, $chgrp);
     }
     return true;
 }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:15,代码来源:class-wp-filesystem-ssh2.php

示例10: copyFile

 /**
  * @param $local
  * @param $remote
  *
  * @throws BuildException
  */
 protected function copyFile($local, $remote)
 {
     $path = rtrim($this->todir, "/") . "/";
     if ($this->fetch) {
         $localEndpoint = $path . $remote;
         $remoteEndpoint = $local;
         $this->log('Will fetch ' . $remoteEndpoint . ' to ' . $localEndpoint, $this->logLevel);
         $ret = @ssh2_scp_recv($this->connection, $remoteEndpoint, $localEndpoint);
         if ($ret === false) {
             throw new BuildException("Could not fetch remote file '" . $remoteEndpoint . "'");
         }
     } else {
         $localEndpoint = $local;
         $remoteEndpoint = $path . $remote;
         if ($this->autocreate) {
             ssh2_sftp_mkdir($this->sftp, dirname($remoteEndpoint), is_null($this->mode) ? 0777 : $this->mode, true);
         }
         $this->log('Will copy ' . $localEndpoint . ' to ' . $remoteEndpoint, $this->logLevel);
         $ret = false;
         // If more than "$this->heuristicDecision" successfully send files by "ssh2.sftp" over "ssh2_scp_send"
         // then ship this step (task finish ~40% faster)
         if ($this->heuristicScpSftp < $this->heuristicDecision) {
             if (null !== $this->mode) {
                 $ret = @ssh2_scp_send($this->connection, $localEndpoint, $remoteEndpoint, $this->mode);
             } else {
                 $ret = @ssh2_scp_send($this->connection, $localEndpoint, $remoteEndpoint);
             }
         }
         // sometimes remote server allow only create files via sftp (eg. phpcloud.com)
         if (false === $ret && $this->sftp) {
             // mark failure of "scp"
             --$this->heuristicScpSftp;
             // try create file via ssh2.sftp://file wrapper
             $fh = @fopen("ssh2.sftp://{$this->sftp}/{$remoteEndpoint}", 'wb');
             if (is_resource($fh)) {
                 $ret = fwrite($fh, file_get_contents($localEndpoint));
                 fclose($fh);
                 // mark success of "sftp"
                 $this->heuristicScpSftp += 2;
             }
         }
         if ($ret === false) {
             throw new BuildException("Could not create remote file '" . $remoteEndpoint . "'");
         }
     }
     $this->counter++;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:53,代码来源:ScpTask.php

示例11: mkdir

 /**
  * Create a directory if it doesn't exist. The operation is implicitly recursive, i.e. it will create all
  * intermediate directories if they do not already exist.
  *
  * @param   string   $dirName      The full path of the directory to create
  * @param   integer  $permissions  The permissions of the created directory
  *
  * @return  boolean  True on success
  */
 public function mkdir($dirName, $permissions = 0755)
 {
     $targetDir = $this->translatePath($dirName);
     $targetDir = trim($targetDir, '/');
     $ret = @ssh2_sftp_mkdir($this->sftpHandle, $targetDir, $permissions, true);
     return true;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:16,代码来源:Sftp.php

示例12: doMkDir

 protected function doMkDir($remote_path)
 {
     $remote_path = ltrim($remote_path, '/');
     return ssh2_sftp_mkdir($this->getSftpConnection(), $remote_path);
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:5,代码来源:sftpMgr.class.php

示例13: mkdir

 /**
  * @param $dirName
  * @param int $mode
  * @param bool $recursive
  * @return bool
  */
 public function mkdir($dirName, $mode = 0777, $recursive = FALSE)
 {
     return ssh2_sftp_mkdir($this->getSftpResource(), $dirName, $mode, $recursive);
 }
开发者ID:brabijan,项目名称:ssh,代码行数:10,代码来源:RemoteFilesystem.php

示例14: mkdir

 /**
  * Create a directory
  *
  * @version 1.0
  * @access  public
  * @param   string
  * @return  bool
  */
 public function mkdir($path = '', $permissions = '0777')
 {
     if ($path == '' || !$this->_is_conn()) {
         return FALSE;
     }
     $result = @ssh2_sftp_mkdir($this->sftp, $path, $permissions, TRUE);
     if ($result === FALSE) {
         if ($this->debug == TRUE) {
             $this->_error('sftp_unable_to_mkdir');
         }
         return FALSE;
     }
     return TRUE;
 }
开发者ID:telldrak,项目名称:codeigniter-sftp,代码行数:22,代码来源:Sftp.php

示例15: createFolder

 public function createFolder(string $path, int $mode = 0777, bool $recursive = true) : bool
 {
     if (@ssh2_sftp_mkdir($this->connect, $path, $mode, $recursive)) {
         return true;
     } else {
         throw new FolderAllreadyException($path);
     }
 }
开发者ID:znframework,项目名称:znframework,代码行数:8,代码来源:InternalSSH.php


注:本文中的ssh2_sftp_mkdir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。