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


PHP Net_SFTP::rawlist方法代码示例

本文整理汇总了PHP中Net_SFTP::rawlist方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::rawlist方法的具体用法?PHP Net_SFTP::rawlist怎么用?PHP Net_SFTP::rawlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_SFTP的用法示例。


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

示例1: _getListDirectory

 /**
  * return the list of directory
  *
  * @param string $folder directory path
  *
  * @return array
  * @throws CMbException
  */
 private function _getListDirectory($folder = ".")
 {
     if (!$this->connexion) {
         throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname);
     }
     /**
      * group by directory
      * size - uid -gid - permissions - atime - mtime - type
      */
     if (!($files = $this->connexion->rawlist($folder))) {
         throw new CMbException("CSourceSFTP-getlistfiles-failed", $this->hostname);
     }
     CMbArray::extract($files, ".");
     CMbArray::extract($files, "..");
     $list = array();
     foreach ($files as $key => $_file) {
         if ($_file["type"] !== 2) {
             continue;
         }
         $list[$key] = $_file;
     }
     return $list;
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:31,代码来源:CSFTP.class.php

示例2: send

 public static function send($settings = array(), $files = array(), $send_id = '')
 {
     global $pb_backupbuddy_destination_errors;
     if ('1' == $settings['disabled']) {
         $pb_backupbuddy_destination_errors[] = __('Error #48933: This destination is currently disabled. Enable it under this destination\'s Advanced Settings.', 'it-l10n-backupbuddy');
         return false;
     }
     if (!is_array($files)) {
         $files = array($files);
     }
     pb_backupbuddy::status('details', 'FTP class send() function started.');
     self::_init();
     // Connect to server.
     $server = $settings['address'];
     $port = '22';
     // Default sFTP port.
     if (strstr($server, ':')) {
         // Handle custom sFTP port.
         $server_params = explode(':', $server);
         $server = $server_params[0];
         $port = $server_params[1];
     }
     pb_backupbuddy::status('details', 'Connecting to sFTP server...');
     $sftp = new Net_SFTP($server, $port);
     if (!$sftp->login($settings['username'], $settings['password'])) {
         pb_backupbuddy::status('error', 'Connection to sFTP server FAILED.');
         pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
         return false;
     } else {
         pb_backupbuddy::status('details', 'Success connecting to sFTP server.');
     }
     pb_backupbuddy::status('details', 'Attempting to create path (if it does not exist)...');
     if (true === $sftp->mkdir($settings['path'])) {
         // Try to make directory.
         pb_backupbuddy::status('details', 'Directory created.');
     } else {
         pb_backupbuddy::status('details', 'Directory not created.');
     }
     // Change to directory.
     pb_backupbuddy::status('details', 'Attempting to change into directory...');
     if (true === $sftp->chdir($settings['path'])) {
         pb_backupbuddy::status('details', 'Changed into directory `' . $settings['path'] . '`. All uploads will be relative to this.');
     } else {
         pb_backupbuddy::status('error', 'Unable to change into specified path. Verify the path is correct with valid permissions.');
         pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
         return false;
     }
     // Upload files.
     $total_transfer_size = 0;
     $total_transfer_time = 0;
     foreach ($files as $file) {
         if (!file_exists($file)) {
             pb_backupbuddy::status('error', 'Error #859485495. Could not upload local file `' . $file . '` to send to sFTP as it does not exist. Verify the file exists, permissions of file, parent directory, and that ownership is correct. You may need suphp installed on the server.');
         }
         if (!is_readable($file)) {
             pb_backupbuddy::status('error', 'Error #8594846548. Could not read local file `' . $file . '` to send to sFTP as it is not readable. Verify permissions of file, parent directory, and that ownership is correct. You may need suphp installed on the server.');
         }
         $filesize = filesize($file);
         $total_transfer_size += $filesize;
         $destination_file = basename($file);
         pb_backupbuddy::status('details', 'About to put to sFTP local file `' . $file . '` of size `' . pb_backupbuddy::$format->file_size($filesize) . '` to remote file `' . $destination_file . '`.');
         $send_time = -microtime(true);
         $upload = $sftp->put($destination_file, $file, NET_SFTP_LOCAL_FILE);
         $send_time += microtime(true);
         $total_transfer_time += $send_time;
         if ($upload === false) {
             // Failed sending.
             $error_message = 'ERROR #9012b ( http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#9012 ).  sFTP file upload failed. Check file permissions & disk quota.';
             pb_backupbuddy::status('error', $error_message);
             backupbuddy_core::mail_error($error_message);
             pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
             return false;
         } else {
             // Success sending.
             pb_backupbuddy::status('details', 'Success completely sending `' . basename($file) . '` to destination.');
             // Start remote backup limit
             if ($settings['archive_limit'] > 0) {
                 pb_backupbuddy::status('details', 'Archive limit enabled. Getting contents of backup directory.');
                 $contents = $sftp->rawlist($settings['path']);
                 // already in destination directory/path.
                 // Create array of backups
                 $bkupprefix = backupbuddy_core::backup_prefix();
                 $backups = array();
                 foreach ($contents as $filename => $backup) {
                     // check if file is backup
                     $pos = strpos($filename, 'backup-' . $bkupprefix . '-');
                     if ($pos !== FALSE) {
                         $backups[] = array('file' => $filename, 'modified' => $backup['mtime']);
                     }
                 }
                 function backupbuddy_number_sort($a, $b)
                 {
                     return $a['modified'] < $b['modified'];
                 }
                 // Sort by modified using custom sort function above.
                 usort($backups, 'backupbuddy_number_sort');
                 if (count($backups) > $settings['archive_limit']) {
                     pb_backupbuddy::status('details', 'More backups found (' . count($backups) . ') than limit permits (' . $settings['archive_limit'] . ').' . print_r($backups, true));
                     $delete_fail_count = 0;
                     $i = 0;
//.........这里部分代码省略.........
开发者ID:elephantcode,项目名称:elephantcode,代码行数:101,代码来源:init.php

示例3: rawls

 public function rawls()
 {
     $list = $this->_connection->rawlist();
     return $list;
 }
开发者ID:Airmal,项目名称:Magento-Em,代码行数:5,代码来源:Sftp.php

示例4: path

$sftp = new Net_SFTP($server, $port);
if (!$sftp->login($destination['username'], $destination['password'])) {
    pb_backupbuddy::status('error', 'Connection to sFTP server FAILED.');
    return false;
} else {
    pb_backupbuddy::status('details', 'Success connecting to sFTP server.');
}
pb_backupbuddy::status('details', 'Attempting to create path (if it does not exist)...');
if (true === $sftp->mkdir($destination['path'])) {
    // Try to make directory.
    pb_backupbuddy::status('details', 'Directory created.');
} else {
    pb_backupbuddy::status('details', 'Directory not created.');
}
// List files.
$files = $sftp->rawlist($destination['path']);
$backups = array();
$backup_list_temp = array();
foreach ($files as $filename => $file) {
    if (false === stristr($filename, 'backup')) {
        // only show backup files
        continue;
    }
    if (stristr($filename, '-db-') !== false) {
        $backup_type = 'Database';
    } elseif (stristr($filename, '-full-') !== false) {
        $backup_type = 'Full';
    } else {
        $backup_type = 'Unknown';
    }
    $last_modified = $file['mtime'];
开发者ID:elephantcode,项目名称:elephantcode,代码行数:31,代码来源:_manage.php

示例5: file_list


//.........这里部分代码省略.........
             if (!file_exists($game_dir)) {
                 return 'That file doesnt exist or the webserver cannot view it.';
             }
             // Read file
             $fh = fopen($game_dir, "rb");
             $file_content = fread($fh, filesize($game_dir));
             fclose($fh);
             // Return remote file content
             return $file_content;
         }
         ##########################################################################################
         // Continue with directory listing
         if (GPXDEBUG) {
             $add_path = '(' . $game_dir . ') ';
         } else {
             $add_path = '';
         }
         if (!is_dir($game_dir)) {
             die('Sorry, that game directory ' . $add_path . 'does not exist!');
         }
         $dir = dir($game_dir);
         $dir_arr = array();
         $count_dir = 0;
         // Permission errors etc
         if (!opendir($game_dir)) {
             return 'err_opendir';
         }
         // Loop over files, no . or .. dirs
         while (($file = $dir->read()) !== false) {
             if (!preg_match('/^\\.+/', $file)) {
                 $full_path = $game_dir . '/' . $file;
                 if (is_dir($full_path)) {
                     $thetype = '2';
                 } else {
                     $thetype = '1';
                 }
                 #$dir_arr[$count_dir]['name']      = $file;
                 #$dir_arr[$count_dir]['size']      = filesize($full_path);
                 #$dir_arr[$count_dir]['mtime']     = filemtime($full_path);
                 #$dir_arr[$count_dir]['atime']     = fileatime($full_path);
                 #$dir_arr[$count_dir]['perms']     = fileperms($full_path);
                 #$dir_arr[$count_dir]['type']      = $thetype;
                 $dir_arr[$file]['size'] = filesize($full_path);
                 $dir_arr[$file]['mtime'] = filemtime($full_path);
                 $dir_arr[$file]['atime'] = fileatime($full_path);
                 $dir_arr[$file]['uid'] = fileowner($full_path);
                 $dir_arr[$file]['gid'] = filegroup($full_path);
                 $dir_arr[$file]['permissions'] = fileperms($full_path);
                 $dir_arr[$file]['type'] = $thetype;
             }
             $count_dir++;
         }
         $dir->close();
         return $dir_arr;
     } else {
         // Not browsing for templates
         if (!$tpl_browse) {
             // Use real SSO user's login, not gpx login
             $sso_info = $Network->sso_info($srvid);
             $ssh_user = $sso_info['sso_user'];
             $ssh_pass = $sso_info['sso_pass'];
             $sso_username = $sso_info['username'];
             $sso_gamedir = $sso_info['game_path'];
             // Set game dir
             $game_dir = $sso_gamedir;
             if (GPXDEBUG) {
                 echo "DEBUG: Gamedir: {$sso_gamedir}, SSO User: {$ssh_user}, Username: {$sso_username}<br>";
             }
             // File Contents
             if (preg_match('/\\.(txt|cfg|rc|log|ini|inf|vdf|yml|properties|json|conf)$/i', $dir)) {
                 if ($tpl_browse) {
                     return 'Sorry, you cannot edit files while browsing for templates!';
                 }
                 $net_cmd = 'FileContent -f ' . $game_dir . '/' . $dir;
                 $file_content = $Network->runcmd($this_netid, $netinfo, $net_cmd, true, $srvid);
                 // Return remote file content
                 return $file_content;
             }
         } else {
             // Use normal SSH homedir
             $game_dir = $ssh_homedir;
         }
         ##########################################################################################
         // PHPSecLib (Pure-PHP SSH Implementation)
         require DOCROOT . '/includes/SSH/Net/SFTP.php';
         // Setup Connection
         $sftp = new Net_SFTP($ssh_ip, $ssh_port, 12);
         // Test login
         if (!$sftp->login($ssh_user, $ssh_pass)) {
             return 'ERROR: Failed to login to the remote server';
         }
         // Append new directory to basedir
         if ($dir) {
             $game_dir .= '/' . $dir;
         }
         // Get raw file list
         $file_list = $sftp->rawlist($game_dir);
         return $file_list;
     }
 }
开发者ID:fritz-net,项目名称:GamePanelX-V3,代码行数:101,代码来源:files.php


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