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


PHP Ftp::nlist方法代码示例

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


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

示例1: purge

 /**
  * Recursive deletes path.
  * @param  string
  * @return void
  */
 private function purge($path, $onlyContent = FALSE)
 {
     static $counter;
     echo str_pad(str_repeat('.', $counter++ % 40), 40), "\r";
     if (!$onlyContent && $this->ftp->tryDelete($path)) {
         return;
     }
     foreach ((array) $this->ftp->nlist($path) as $file) {
         if ($file != NULL && !preg_match('#(^|/)\\.+$#', $file)) {
             // intentionally ==
             $file = strpos($file, '/') === FALSE ? "{$path}/{$file}" : $file;
             if ($file !== $path) {
                 $this->purge($file);
             }
         }
     }
     if (!$onlyContent) {
         $this->ftp->tryRmdir($path);
     }
 }
开发者ID:ondrs,项目名称:ftp-deployment,代码行数:25,代码来源:Deployment.php

示例2: foreach

&style=bloco" class="btn btn-success" style="float: right; width: 100px;">Bloco</a>
<?php 
} else {
    ?>
    <a href="<?php 
    echo $Ftp->getPage() . "&ftp=" . $Ftp->getUrl();
    ?>
&style=lista" class="btn btn-primary" style="float: right; width: 100px;">Lista</a>
<?php 
}
echo "</div>";
?>

<div class="well">
    <?php 
$lista = !empty($dir) ? $Ftp->nlist($dir) : $Ftp->nlist('.');
if (empty($file)) {
    $i = 0;
    $class = $style == 'lista' ? 'list-group' : 'row';
    echo "<div class=\"{$class}\">";
    foreach ($lista as $url) {
        $title = $Ftp->UrlToDir($url);
        if ($title != '.tmb' && $title != '.quarantine') {
            if (empty($style) || $style == "bloco") {
                if ($i % 6 == 0) {
                    echo "</div><div class=\"row\">";
                }
            }
            if (empty($style) || $style == "bloco") {
                if ($Ftp->ftp_is_dir($url)) {
                    $Ftp->getIcon("&ftp={$url}", $title, "pasta");
开发者ID:adrianosilvareis,项目名称:intranet,代码行数:31,代码来源:qualidade.php

示例3: fn_copy_by_ftp

/**
 * Copies files using FTP access
 *
 * @param string $source Absolute path (non-ftp) to source dir/file
 * @param string $destination Absolute path (non-ftp) to destination dir/file
 * @param array $ftp_access
 *      array(
 *          'hostname',
 *          'username',
 *          'password',
 *          'directory'
 *      )
 * @return bool true if all files were copied or (string) Error message
 */
function fn_copy_by_ftp($source, $destination, $ftp_access)
{
    try {
        $ftp = new Ftp();
        $ftp->connect($ftp_access['hostname']);
        $ftp->login($ftp_access['username'], $ftp_access['password']);
        $ftp->chdir($ftp_access['directory']);
        $files = $ftp->nlist('');
        if (!empty($files) && in_array('config.php', $files)) {
            $ftp_destination = str_replace(Registry::get('config.dir.root'), '', $destination);
            if (is_file($source)) {
                // File
                try {
                    $file = ltrim($ftp_destination, '/');
                    $ftp->put($file, $source, FTP_BINARY);
                } catch (FtpException $e) {
                    throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                }
            } else {
                // Dir
                $ftp->chdir($ftp_access['directory'] . $ftp_destination);
                $struct = fn_get_dir_contents($source, false, true, '', '', true);
                foreach ($struct as $file) {
                    $dir = dirname($file);
                    if (!$ftp->isDir($dir)) {
                        try {
                            $ftp->mkDirRecursive($dir);
                        } catch (FtpException $e) {
                            throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                        }
                    }
                    try {
                        $ftp->put($file, $source . $file, FTP_BINARY);
                    } catch (FtpException $e) {
                        throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                    }
                }
            }
            return true;
        } else {
            throw new FtpException('ftp_directory_is_incorrect');
        }
    } catch (FtpException $e) {
        return __('invalid_ftp_access') . ': ' . $e->getMessage();
    }
    return false;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:61,代码来源:fn.fs.php

示例4: getGitDiff

 /**
  * Gets a list of files to be uploaded based on the difference between HEAD
  * and the commit last deployed.
  *
  * @param \Ftp $ftp An active FTP connection.
  *
  * @return string[] An array of file names to upload.
  */
 protected function getGitDiff(\Ftp $ftp)
 {
     $this->printTaskInfo('Checking remote site for Git info...');
     $ftp->chdir($this->targetDirectory);
     if (in_array('.git-commit', $ftp->nlist('.'))) {
         $tempHandle = fopen('php://temp', 'r+');
         if ($ftp->fget($tempHandle, '.git-commit', FTP_ASCII, 0)) {
             rewind($tempHandle);
             $commitId = stream_get_contents($tempHandle);
             $this->printTaskInfo('Remote site has version ' . $commitId . '.');
             $this->printTaskInfo(' Scanning for changes...');
             $result = $this->taskExec('git')->arg('diff')->arg('--name-only')->arg('--diff-filter=ACMRT')->arg($commitId)->arg('HEAD')->run();
             return preg_split('/[\\r\\n]+/', trim($result->getMessage()));
         }
     }
     $this->printTaskInfo('No Git info found on remote site.');
     $this->printTaskInfo('Adding all files in repo...');
     // No commit saved on remote site; deploy everything in repo
     $result = $this->taskExec('git')->arg('ls-files')->run();
     return preg_split('/[\\r\\n]+/', trim($result->getMessage()));
 }
开发者ID:coderstephen,项目名称:robo-ftp,代码行数:29,代码来源:FtpDeployTask.php


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