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


PHP RecursiveDirectoryIterator::setFlags方法代码示例

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


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

示例1: zipData

function zipData($source, $destination)
{
    if (extension_loaded('zip')) {
        if (file_exists($source)) {
            $zip = new ZipArchive();
            if ($zip->open($destination, ZIPARCHIVE::CREATE)) {
                $source = realpath($source);
                if (is_dir($source)) {
                    $iterator = new RecursiveDirectoryIterator($source);
                    // skip dot files while iterating
                    $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
                    $files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
                    foreach ($files as $file) {
                        $file = realpath($file);
                        if (is_dir($file)) {
                            $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                        } else {
                            if (is_file($file)) {
                                $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                            }
                        }
                    }
                } else {
                    if (is_file($source)) {
                        $zip->addFromString(basename($source), file_get_contents($source));
                    }
                }
            }
            echo $destination . ' zip: successfully...';
            echo "\n";
            return $zip->close();
        }
    }
    return false;
}
开发者ID:phn007,项目名称:BuildHtml,代码行数:35,代码来源:zip.php

示例2: listPosts

    public function listPosts()
    {
        $path = null;
        $timestamp = null;
        $dirname = $this->settings->posts_dir;
        $dir = new \RecursiveDirectoryIterator($dirname);
        $dir->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
        ob_start();
        ?>
        <div class="row">
            <table class="post-table">
                <tr>
                    <th>Name</th>
                    <th>Date created</th>
                </tr>
                
        <?php 
        foreach ($dir as $fileinfo) {
            if ($fileinfo->getMTime() > $timestamp) {
                // current file has been modified more recently
                // than any other file we've checked until now
                $path = $fileinfo->getFilename();
                $modified = $fileinfo->getMTime();
                $created = $fileinfo->getCTime();
                $linkUrl = preg_replace('/\\.[^.\\s]{1,4}$/', '', $path);
                echo "<tr><td><a href='?action=edit&post=" . $linkUrl . "'>" . $path . "</a></td>";
                echo "<td>" . date("F d Y H:i:s.", $created) . "</td></tr>";
            }
        }
        ?>
            </table>
        </div>

<style>
    .post-table {
        width: 80%;
        margin: 50px auto;
        text-align: center;
        border: solid 1px #ddd;
    }
    .post-table th {
        font-weight: bold;
        
    }
    .post-table th,
    .post-table td {
        text-align: left;
        padding: 5px;
        border: solid 1px #ddd;
    }

</style>



        <?php 
        return ob_get_clean();
    }
开发者ID:dangerdan,项目名称:Dropplets2,代码行数:58,代码来源:PostManager.php

示例3: routesInDirectory

function routesInDirectory($app = '')
{
    $routeDir = app_path('Http/Routes/' . $app . ($app !== '' ? '/' : NULL));
    $iterator = new RecursiveDirectoryIterator($routeDir);
    $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
    foreach ($iterator as $route) {
        $isDotFile = strpos($route->getFilename(), '.') === 0;
        if (!$isDotFile && !$route->isDir()) {
            require $routeDir . $route->getFilename();
        }
    }
}
开发者ID:RoryStolzenberg,项目名称:spacexstats,代码行数:12,代码来源:routes.php

示例4: getOutdatedFiles

 /**
  * Retrieves old CSS files and list them
  *
  * @param $ttl int
  * @return array
  */
 protected function getOutdatedFiles($ttl)
 {
     $outdated = array();
     $time = time();
     $dir = new RecursiveDirectoryIterator($this->configuration->getUploadDir());
     $dir->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
     /*
      * Collecting CSS files
      */
     $files = new RegexIterator(new RecursiveIteratorIterator($dir), '#.css#U', RecursiveRegexIterator::ALL_MATCHES);
     /*
      * Checking expiry
      */
     foreach ($files as $filepath => $match) {
         filemtime($filepath) + $ttl < $time ? array_push($outdated, $filepath) : null;
     }
     return $outdated;
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:24,代码来源:Garbagecollector.class.php

示例5: zipData

 public function zipData($source, $destination)
 {
     global $Language;
     $archiveName = 'backup-' . time() . '.zip';
     // Archive name
     if (extension_loaded('zip')) {
         if (file_exists($source)) {
             $zip = new ZipArchive();
             if ($zip->open($destination, ZIPARCHIVE::CREATE)) {
                 $source = realpath($source);
                 if (is_dir($source)) {
                     $iterator = new RecursiveDirectoryIterator($source);
                     // skip dot files while iterating
                     $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
                     $files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
                     foreach ($files as $file) {
                         $file = realpath($file);
                         if (is_dir($file)) {
                             $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                         } else {
                             if (is_file($file)) {
                                 $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                             }
                         }
                     }
                 } else {
                     if (is_file($source)) {
                         $zip->addFromString(basename($source), file_get_contents($source));
                     }
                 }
             }
             if (!$zip->close()) {
                 Alert::set($Language->get("There was a problem writing the ZIP archive."));
                 Redirect::page('admin', 'configure-plugin/pluginBackup');
             } else {
                 Alert::set($Language->get("Successfully created the ZIP Archive!"));
                 Redirect::page('admin', 'configure-plugin/pluginBackup');
             }
             // close the zip file
             $zip->close();
         }
     }
     return false;
 }
开发者ID:joryphillips,项目名称:bludit-plugins,代码行数:44,代码来源:plugin.php

示例6: make

 /**
  * @param string $dir
  * @return FileIndex
  */
 public static function make($dir)
 {
     $dirIterator = new \RecursiveDirectoryIterator($dir);
     $dirIterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
     $recursiveIterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
     $results = array();
     foreach ($recursiveIterator as $file) {
         /** @var \SplFileInfo $file */
         // ignore non files
         if (!$file->isFile()) {
             continue;
         }
         // ignore non php files
         $ext = strtolower($file->getExtension());
         if ($ext !== 'php') {
             continue;
         }
         $results[] = $file->getPathname();
     }
     return new self($results);
 }
开发者ID:superbalist,项目名称:php-money,代码行数:25,代码来源:FileIndex.php

示例7: cmd_artifact

 public function cmd_artifact(array $params = array())
 {
     \System\Directory::check(BASE_DIR . static::DIR_PACKAGES);
     $target = BASE_DIR . static::DIR_PACKAGES . '/artifact.tar';
     $result = $target . '.gz';
     if (isset($params[0])) {
         $target = $params[0];
     }
     if (file_exists($target)) {
         unlink($target);
     }
     if (file_exists($result)) {
         unlink($result);
     }
     $iter = new \RecursiveDirectoryIterator(BASE_DIR);
     $iter->setFlags(\FileSystemIterator::SKIP_DOTS);
     $iter = new ProjectDirectoryRecursiveIterator($iter);
     $iter = new \RecursiveIteratorIterator($iter);
     $archive = new \PharData($target);
     $archive->buildFromIterator($iter, BASE_DIR);
     $archive->compress(\Phar::GZ);
     unlink($target);
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:23,代码来源:package.php

示例8: RecursiveDirectoryIterator

<!DOCTYPE HTML>
<html>
<head>
<meta  charset="utf-8">
<title>RecursiveDirectoryIterator</title>
</head>

<body>
<pre>
<?php 
$files = new RecursiveDirectoryIterator('../images');
$files->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($files);
foreach ($files as $file) {
    echo $file->getRealPath() . '<br>';
}
?>
</pre>
</body>
</html>
开发者ID:Remekgc,项目名称:Vef,代码行数:20,代码来源:iterator_04.php

示例9: buildFileList

 private static function buildFileList()
 {
     self::log();
     self::log('reading MPQdata from ' . self::$srcDir . ' to list for first time use...');
     $setupDirs = glob('setup/*');
     foreach ($setupDirs as $sd) {
         if (mb_substr(self::$srcDir, -1) == '/') {
             self::$srcDir = mb_substr(self::$srcDir, 0, -1);
         }
         if (mb_substr($sd, -1) == '/') {
             $sd = mb_substr($sd, 0, -1);
         }
         if (Util::lower($sd) == Util::lower(self::$srcDir)) {
             self::$srcDir = $sd . '/';
             break;
         }
     }
     try {
         $iterator = new RecursiveDirectoryIterator(self::$srcDir);
         $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
         foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST) as $path) {
             $_ = str_replace('\\', '/', $path->getPathname());
             self::$mpqFiles[strtolower($_)] = $_;
         }
         self::log('done');
         self::log();
     } catch (UnexpectedValueException $e) {
         self::log('- mpqData dir ' . self::$srcDir . ' does not exist', self::LOG_ERROR);
         return false;
     }
     return true;
 }
开发者ID:saqar,项目名称:aowow,代码行数:32,代码来源:CLISetup.class.php

示例10: array

<?php

namespace App\Modules\mod_slider;

$files = new \RecursiveDirectoryIterator("./public/images/slider/");
$files->setFlags(\FilesystemIterator::UNIX_PATHS | \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($files, \RecursiveIteratorIterator::SELF_FIRST);
$files->setMaxDepth(2);
$extension = array('jpg', 'png', 'jpeg');
?>

<div class="wrapper">
	<div class="slider-wrapper theme-default">
		<div class="ribbon"></div>
		<div id="slider" class="nivoSlider">
            <?php 
foreach ($files as $key => $file) {
    if (in_array($file->getExtension(), $extension)) {
        echo "<img src='{$file}' />";
    }
}
?>
		</div><!-- END of slider-wrapper -->
	</div><!-- END of nivoSlider -->
</div><!-- END of WRAPPER -->


<link rel="stylesheet" href="./public/js/nivo-slider/nivo-slider.css" type="text/css" />
<link rel="stylesheet" href="./public/js/nivo-slider/themes/default/default.css" type="text/css" />

<script type="text/javascript" src="./public/js/nivo-slider/jquery.nivo.slider.pack.js"></script>
开发者ID:butkica,项目名称:Deluxe,代码行数:31,代码来源:index.php

示例11: count

    }
    echo '<br>', I18N::plural('%1$s file was extracted in %2$s seconds.', '%1$s files were extracted in %2$s seconds.', count($res), count($res), I18N::number($end_time - $start_time, 2)), $icon_success;
} else {
    echo '<br>', I18N::translate('An error occurred when unzipping the file.'), $icon_failure;
    echo '<pre>', $archive->errorInfo(true), '</pre>';
    echo '</li></ul></form>';
    return;
}
echo '</li>';
////////////////////////////////////////////////////////////////////////////////
// This is it - take the site offline first
////////////////////////////////////////////////////////////////////////////////
echo '<li>', I18N::translate('Check file permissions…');
reset_timeout();
$iterator = new \RecursiveDirectoryIterator($zip_dir);
$iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
foreach (new \RecursiveIteratorIterator($iterator) as $file) {
    $file = WT_ROOT . substr($file, strlen($zip_dir) + 1);
    if (file_exists($file) && (!is_readable($file) || !is_writable($file))) {
        echo '<br>', I18N::translate('The file %s could not be updated.', Html::filename($file)), $icon_failure;
        echo '</li></ul>';
        echo '<p class="error">', I18N::translate('To complete the upgrade, you should install the files manually.'), '</p>';
        echo '<p>', I18N::translate('The new files are currently located in the folder %s.', Html::filename($zip_dir)), '</p>';
        echo '<p>', I18N::translate('Copy these files to the folder %s, replacing any that have the same name.', Html::filename(WT_ROOT)), '</p>';
        echo '<p>', I18N::translate('To prevent visitors from accessing the website while you are in the middle of copying files, you can temporarily create a file %s on the server. If it contains a message, it will be displayed to visitors.', Html::filename($lock_file)), '</p>';
        return;
    }
}
echo '<br>', I18N::translate('All files have read and write permission.'), $icon_success;
echo '</li>';
////////////////////////////////////////////////////////////////////////////////
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:31,代码来源:admin_site_upgrade.php

示例12: _refreshLocal

 protected function _refreshLocal($myrole, $drivers)
 {
     $job = $this->_out->jobStart("traversing file system starting at {$this->_baseDir}");
     /* @var $compare Compare_Sqlite */
     $compare = $drivers[Core_Engine::ROLE_COMPARE];
     $stat = $this->_fileStat;
     $it = new RecursiveDirectoryIterator($this->_baseDir);
     $it->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
     //$it = new DirnameFilter($it, "/informa/i");
     if (isset($this->_options['filter'])) {
         $this->_out->logNotice(">>>applying filter " . $this->_options['filterType']);
         $filterConf = $this->_options['filter'][$this->_options['filterType']];
         /** @var $filter Filter_Interface */
         $filter = new $filterConf['class']($filterConf);
         $filter->setIterator($it);
         $it = $filter->applyFilters();
     }
     $itemCount = 0;
     $this->_trimFromBegin = strlen($this->_baseDir);
     $compare->updateFromLocalStart();
     foreach (new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST) as $file) {
         /** @var $file SplFileObject */
         //we don't need make entry for not empty folder
         if ($file->isDir() && !Storage_Filesystem_FileStat::isEmptyDir((string) $file)) {
             continue;
         }
         $file = (string) $file;
         $obj = Core_FsObject::factoryFromStat($this->_makePath($file), $stat->getStat($file));
         $compare->updateFromLocal($obj);
         $itemCount++;
     }
     $compare->updateFromLocalEnd();
     $this->_out->jobEnd($job, "updated info about {$itemCount} files");
 }
开发者ID:dannypenrose,项目名称:xtbackup,代码行数:34,代码来源:Filesystem.php

示例13: getFilteredEveApiSubscriberList

 /**
  * @param ContainerInterface $dic
  *
  * @return array
  */
 private function getFilteredEveApiSubscriberList(ContainerInterface $dic) : array
 {
     $flags = \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
     $rdi = new \RecursiveDirectoryIterator($dic['Yapeal.EveApi.dir']);
     $rdi->setFlags($flags);
     /** @noinspection SpellCheckingInspection */
     $rcfi = new \RecursiveCallbackFilterIterator($rdi, function (\SplFileInfo $current, $key, \RecursiveDirectoryIterator $rdi) {
         if ($rdi->hasChildren()) {
             return true;
         }
         $dirs = ['Account', 'Api', 'Char', 'Corp', 'Eve', 'Map', 'Server'];
         $dirExists = in_array(basename(dirname($key)), $dirs, true);
         return $dirExists && $current->isFile() && 'php' === $current->getExtension();
     });
     /** @noinspection SpellCheckingInspection */
     $rii = new \RecursiveIteratorIterator($rcfi, \RecursiveIteratorIterator::LEAVES_ONLY, \RecursiveIteratorIterator::CATCH_GET_CHILD);
     $rii->setMaxDepth(3);
     $fpn = $this->getFpn();
     $files = [];
     foreach ($rii as $file) {
         $files[] = $fpn->normalizeFile($file->getPathname());
     }
     return $files;
 }
开发者ID:yapeal,项目名称:yapeal-ng,代码行数:29,代码来源:EveApiWiring.php

示例14: getRecursiveList

 /**
  * Recursive listing of directory, files and dirs. If a set of extensions is
  * passed only matching files will be returned (do not pass the dot in the extensions)
  *
  * @param string $path Directory where you want to start parsing.
  * @param array $valid_extensions List of accepted extensions in the list, empty array for no filtering.
  * @return
  * ratorIterator of RecursiveDirectoryIterator
  */
 public function getRecursiveList($path, $accept_directories = true, $valid_extensions = array())
 {
     $mode = $this->_getIteratorMode($accept_directories);
     $recursive_dir_iterator = new \RecursiveDirectoryIterator($path);
     $recursive_dir_iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
     if (!empty($valid_extensions)) {
         return new FilterFilesByExtensionIterator(new \RecursiveIteratorIterator($recursive_dir_iterator, $mode, \RecursiveIteratorIterator::CATCH_GET_CHILD), $valid_extensions);
     } else {
         return new \RecursiveIteratorIterator($recursive_dir_iterator, $mode, \RecursiveIteratorIterator::CATCH_GET_CHILD);
     }
 }
开发者ID:ninodafonte,项目名称:SIFO,代码行数:20,代码来源:DirectoryList.php

示例15: json_encode

<?php

$watchFolders = $_POST['foldersToWatch'];
$extensions = $_POST['extensions'];
$extensions = implode('|', $extensions);
$dir = array();
foreach ($watchFolders as $folder) {
    $dirIter = new RecursiveDirectoryIterator($folder);
    $dirIter->setFlags(FilesystemIterator::SKIP_DOTS);
    $recursiveIter = new RecursiveIteratorIterator($dirIter);
    $regexpIter = new RegexIterator($recursiveIter, '/^.*\\.(' . $extensions . ')$/');
    foreach ($regexpIter as $path) {
        $dir[] = $path->getPathName();
    }
}
$files = [];
foreach ($dir as $path) {
    $files[] = filemtime($path);
}
$last = max($files);
header('Content-Type: application/json');
echo json_encode(array('last' => $last));
开发者ID:lce-fr,项目名称:server-livereload,代码行数:22,代码来源:server-livereload.php


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