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


PHP ssh2_sftp_stat函数代码示例

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


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

示例1: stat

 public function stat($path)
 {
     $path = $this->path($path);
     $stat = @ssh2_sftp_stat($this->getSftpResource(), $path);
     // Missing
     if (!$stat) {
         return array('name' => basename($path), 'path' => $path, 'exists' => false);
     }
     // Get extra
     $type = filetype('ssh2.sftp://' . $this->getSftpResource() . $path);
     $rights = substr(sprintf('%o', fileperms('ssh2.sftp://' . $this->getSftpResource() . $path)), -4);
     // Process stat
     $info = array('name' => basename($path), 'path' => $path, 'exists' => true, 'type' => $type, 'uid' => $stat['uid'], 'gid' => $stat['gid'], 'size' => $stat['size'], 'atime' => isset($stat['atime']) ? $stat['atime'] : null, 'mtime' => isset($stat['mtime']) ? $stat['mtime'] : null, 'ctime' => isset($stat['ctime']) ? $stat['ctime'] : null, 'rights' => $rights, 'readable' => $this->checkPerms(0x4, $rights, $stat['uid'], $stat['gid']), 'writable' => $this->checkPerms(0x2, $rights, $stat['uid'], $stat['gid']), 'executable' => $this->checkPerms(0x1, $rights, $stat['uid'], $stat['gid']));
     return $info;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:15,代码来源:Ssh.php

示例2: stat

 /**
  * Remote stat.
  *
  * @param string $path
  *
  * @return array
  */
 public function stat($path)
 {
     ssh2_sftp_stat($this->resource, $path);
 }
开发者ID:moccalotto,项目名称:ssh,代码行数:11,代码来源:Sftp.php

示例3: stat

 /**
  * Stats a file on the remote filesystem
  *
  * @param  string $path The path of the file
  *
  * @return array
  */
 public function stat($path)
 {
     return ssh2_sftp_stat($this->getResource(), $path);
 }
开发者ID:mikemeier,项目名称:php-ssh,代码行数:11,代码来源:Sftp.php

示例4: _connect

 /**
  * Attempts to open a connection to the SSH2 server.
  *
  * @throws Horde_Vfs_Exception
  */
 protected function _connect()
 {
     if ($this->_stream !== false) {
         return;
     }
     if (!extension_loaded('ssh2')) {
         throw new Horde_Vfs_Exception('The SSH2 PECL extension is not available.');
     }
     if (!is_array($this->_params)) {
         throw new Horde_Vfs_Exception('No configuration information specified for SSH2 VFS.');
     }
     $required = array('hostspec', 'username', 'password');
     foreach ($required as $val) {
         if (!isset($this->_params[$val])) {
             throw new Horde_Vfs_Exception(sprintf('Required "%s" not specified in VFS configuration.', $val));
         }
     }
     /* Connect to the ssh2 server using the supplied parameters. */
     if (empty($this->_params['port'])) {
         $this->_stream = @ssh2_connect($this->_params['hostspec']);
     } else {
         $this->_stream = @ssh2_connect($this->_params['hostspec'], $this->_params['port']);
     }
     if (!$this->_stream) {
         $this->_stream = false;
         throw new Horde_Vfs_Exception('Connection to SSH2 server failed.');
     }
     if (!@ssh2_auth_password($this->_stream, $this->_params['username'], $this->_params['password'])) {
         $this->_stream = false;
         throw new Horde_Vfs_Exception('Authentication to SSH2 server failed.');
     }
     /* Create sftp resource. */
     $this->_sftp = @ssh2_sftp($this->_stream);
     if (!empty($this->_params['vfsroot']) && !@ssh2_sftp_stat($this->_sftp, $this->_params['vfsroot']) && !@ssh2_sftp_mkdir($this->_sftp, $this->_params['vfsroot'])) {
         throw new Horde_Vfs_Exception(sprintf('Unable to create VFS root directory "%s".', $this->_params['vfsroot']));
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:42,代码来源:Ssh2.php

示例5: stat

 /**
  * @{inheritDoc}
  */
 public function stat($path = '')
 {
     return $this->doRun(__METHOD__, func_get_args(), ssh2_sftp_stat($this->sftp, $path));
 }
开发者ID:eroluysal,项目名称:shunt,代码行数:7,代码来源:SFTP.php

示例6: getFileList

 /**
  * Gets the files list
  *
  * @param string $remotePath Remote directory path
  * @return array List of files
  * @throws Exception Invalid connection resource! due to use of validateSshResource.
  * @throws Exception Folder does not exist or no permissions to read!
  * @throws Exception Unable to open remote directory!
  */
 public function getFileList($remotePath)
 {
     $this->validateSshResource();
     if (ssh2_sftp_stat($this->getSftpResource(), $remotePath) === false) {
         throw new Exception("Folder does not exist or no permissions to read!");
     }
     $sftp = $this->getSftpResource();
     $handle = opendir("ssh2.sftp://{$sftp}/{$remotePath}");
     if ($handle === false) {
         throw new Exception("Unable to open remote directory!");
     }
     $files = array();
     while (false != ($entry = readdir($handle))) {
         $files[] = $entry;
     }
     return $files;
 }
开发者ID:janladaking,项目名称:CodeIgniter,代码行数:26,代码来源:SftpClient.php

示例7: rename

 /**
  * Renames a remote file.
  *
  * @param string $old_name
  * @param string $new_name
  *
  * @return boolean Returns TRUE on success or FALSE on error
  *
  * @throws \BackBee\Util\Transport\Exception\TransportException Occures if SSH connection is invalid
  */
 public function rename($old_name, $new_name)
 {
     if (null === $this->_sftp_resource) {
         throw new TransportException(sprintf('None SSH connection available.'));
     }
     $old_name = $this->_getAbsoluteRemotePath($old_name);
     $new_name = $this->_getAbsoluteRemotePath($new_name);
     if (false === @ssh2_sftp_stat($this->_sftp_resource, $old_name)) {
         return $this->_trigger_error(sprintf('Could not open remote file: %s.', $old_name));
     }
     if (false !== @ssh2_sftp_stat($this->_sftp_resource, $new_name)) {
         return $this->_trigger_error(sprintf('Remote file already exists: %s.', $new_name));
     }
     if (false === @ssh2_sftp_rename($this->_sftp_resource, $old_name, $new_name)) {
         return $this->_trigger_error(sprintf('Unable to rename %s to %s', $old_name, $new_name));
     }
     return true;
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:28,代码来源:SFTP.php

示例8: _makeDirectory

 /**
  * Creates a nested directory structure on the remote SFTP server
  *
  * @param   string    $dir
  * @param   resource  $sftphandle
  *
  * @return  boolean
  */
 private function _makeDirectory($dir, &$sftphandle)
 {
     $alldirs = explode('/', $dir);
     $previousDir = '';
     foreach ($alldirs as $curdir) {
         $check = $previousDir . '/' . $curdir;
         if (!@ssh2_sftp_stat($sftphandle, $check)) {
             if (ssh2_sftp_mkdir($sftphandle, $check, 0755, true) === false) {
                 $this->setWarning('Could not create SFTP directory ' . $check);
                 return false;
             }
         }
         $previousDir = $check;
     }
     return true;
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:24,代码来源:sftp.php

示例9: isDir

 /**
  * Checks if the given directory exists
  *
  * @param   string   $path         The full path of the remote directory to check
  *
  * @return  boolean  True if the directory exists
  */
 public function isDir($path)
 {
     return @ssh2_sftp_stat($this->sftpHandle, $path);
 }
开发者ID:esorone,项目名称:efcpw,代码行数:11,代码来源:Sftp.php

示例10: newDirectory

 /**
  * newDirectory - Create new directory using the SFTP subsystem from an already connected SSH2 server.
  *
  * @param string $local
  * @param string $remote
  * @param int $mod
  *
  * @throws exception
  */
 public function newDirectory($remote)
 {
     $statinfo = @ssh2_sftp_stat($this->sftp, $remote);
     if (empty($statinfo['size'])) {
         if (!ssh2_sftp_mkdir($this->sftp, $remote)) {
             throw new Exception("Could not create directory {$remote}");
         }
     }
 }
开发者ID:rharris42,项目名称:Lhp,代码行数:18,代码来源:sftp.php

示例11: remote_file_size

 function remote_file_size($file_path)
 {
     $stat = @ssh2_sftp_stat($this->sftp_connection, $file_path);
     return @$stat["size"];
 }
开发者ID:eliagbayani,项目名称:maps_test,代码行数:5,代码来源:SSH2Connection.php

示例12: statinfo

 public function statinfo($file)
 {
     $sftp = ssh2_sftp($this->conn);
     return ssh2_sftp_stat($sftp, $file);
 }
开发者ID:joyerma,项目名称:yongzhuo,代码行数:5,代码来源:ssh.php

示例13: __call

 public function __call($name, $arguments)
 {
     //无需转换的函数
     $list = array('pathinfo', 'basename', 'mb_basename', 'dirname', 'fwrite', 'fclose', 'feof', 'fflush', 'fgetc', 'fgetcsv', 'fgets', 'fgetss', 'flock', 'fpassthru', 'fputcsv', 'fputs', 'fwirte', 'fread', 'fscanf', 'fseek', 'fstat', 'ftell', 'ftruncate', 'rewind');
     if (in_array($name, $list)) {
         return call_user_func_array($name, $arguments);
     }
     //没有开启协议
     if (!ini_get('allow_url_fopen')) {
         $list = array('filesize' => 'size', 'fileowner' => 'uid', 'filegroup' => 'gid', 'fileperms' => 'mode', 'fileatime' => 'atime', 'filemtime' => 'mtime', 'file_exists' => 'file_exists', 'is_dir' => 'is_dir', 'is_file' => 'is_file', 'is_link' => 'is_link', 'is_executable' => 'is_executable', 'is_readable' => 'is_readable', 'is_writable' => 'is_writable', 'is_writeable' => 'is_writable', 'filetype' => 'filetype');
         if (!array_key_exists($name, $list)) {
             throw new Kohana_Exception('"allow_url_fopen" is off!');
         }
         $data = @ssh2_sftp_stat($arguments[0]);
         $data['file_exists'] = $data !== FALSE;
         $data['is_dir'] = ($data['mode'] & 0x4000) == 0x4000;
         $data['is_file'] = ($data['mode'] & 0x8000) == 0x8000;
         $data['is_link'] = ($data['mode'] & 0xa000) == 0xa000;
         $data['is_executable'] = ($data['mode'] & 0x40) == 0x40;
         $data['is_readable'] = ($data['mode'] & 0x100) == 0x100;
         $data['is_writable'] = ($data['mode'] & 0x80) == 0x80;
         if (($perms & 0xc000) == 0xc000) {
             // Socket
             $data['filetype'] = 'socket';
         } elseif (($perms & 0xa000) == 0xa000) {
             // Symbolic Link
             $data['filetype'] = 'link';
         } elseif (($perms & 0x8000) == 0x8000) {
             // Regular
             $data['filetype'] = 'file';
         } elseif (($perms & 0x6000) == 0x6000) {
             // Block special
             $data['filetype'] = 'block';
         } elseif (($perms & 0x4000) == 0x4000) {
             // Directory
             $data['filetype'] = 'dir';
         } elseif (($perms & 0x2000) == 0x2000) {
             // Character special
             $data['filetype'] = 'char';
         } elseif (($perms & 0x1000) == 0x1000) {
             // FIFO pipe
             $data['filetype'] = 'fifo';
         } else {
             // Unknown
             $data['filetype'] = 'unknown';
         }
         return $data[$list[$name]];
     }
     //需要转换路径的的函数
     $list = array('file_exists', 'is_dir', 'is_executable', 'is_file', 'is_link', 'is_readable', 'is_writable', 'is_writeable', 'lchgrp', 'lchown', 'linkinfo', 'tempnam', 'file_get_contents', 'file_put_contents', 'file', 'readfile', 'parse_ini_file', 'fopen', 'disk_free_space', 'diskfreespace', 'disk_total_space', 'chown', 'chgrp', 'fileatime', 'filectime', 'filegroup', 'fileinode', 'filemtime', 'fileowner', 'fileperms', 'filesize', 'filetype', 'touch');
     if (!in_array($name, $list)) {
         throw new Kohana_Exception('Call to undefined function: :class:::function()', array(':class' => __CLASS__, ':function' => $name));
     }
     //将路径变为SFTP路径
     $arguments[0] = $this->format_sftp_path($arguments[0]);
     return call_user_func_array($name, $arguments);
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:57,代码来源:SSH.php

示例14: doFileExists

 protected function doFileExists($remote_file)
 {
     $sftp = $this->getSftpConnection();
     $stats = @ssh2_sftp_stat($sftp, $remote_file);
     return $stats !== false;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:6,代码来源:sftpMgr.class.php

示例15: stat

 public function stat($remote)
 {
     $sftp = @ssh2_sftp($this->conn_);
     return ssh2_sftp_stat($sftp, $remote);
 }
开发者ID:nicevoice,项目名称:yhtx,代码行数:5,代码来源:Sftp.php


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