本文整理汇总了PHP中getFileList函数的典型用法代码示例。如果您正苦于以下问题:PHP getFileList函数的具体用法?PHP getFileList怎么用?PHP getFileList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getFileList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileList
function getFileList($path)
{
global $list;
global $i;
$directory = dir($path);
while ($entry = $directory->read()) {
if ($entry != "." && $entry != "..") {
if (Is_Dir($path . "/" . $entry) && !eregi("__zbSessionTMP", $path . "/" . $entry)) {
getFileList($path . "/" . $entry);
} else {
if (!eregi("now_connect.php", $path . "/" . $entry) && !eregi("now_member_connect.php", $path . "/" . $entry) && !eregi("__zbSessionTMP", $path . "/" . $entry)) {
$list[] = str_replace("../", "", $path . "/" . $entry);
echo ".";
$i++;
if ($i > 100) {
$i = 0;
echo "\n\t\t";
}
}
flush();
}
}
}
$directory->close();
}
示例2: getFileList
/**
* Return array of filenames to convert
* @param string $dirName
* @return mixed
*/
function getFileList($dirName = null)
{
if (!is_string($dirName)) {
return false;
}
if (!is_dir($dirName)) {
return false;
}
if (!is_readable($dirName)) {
return false;
}
clearstatcache();
$ret_ar = array();
if (!($dh = opendir($dirName))) {
return false;
}
while (false !== ($file = readdir($dh))) {
if ($file == '..' or $file == '.') {
continue;
}
$cur_file = $dirName . '/' . $file;
if (is_dir($cur_file)) {
$tmp_ar = getFileList($cur_file);
if (is_array($tmp_ar)) {
$ret_ar = array_merge($ret_ar, $tmp_ar);
}
}
$ret_ar[] = $cur_file;
}
closedir($dh);
natcasesort($ret_ar);
return $ret_ar;
}
示例3: getFileList
/**
* getFileList
*
* @param string $dir_path
*/
function getFileList($dir_path)
{
$file_list = array();
$dir = opendir($dir_path);
if ($dir == false) {
return false;
}
while ($file_path = readdir($dir)) {
$full_path = $dir_path . '/' . $file_path;
if (is_file($full_path)) {
// テストケースのファイルのみ読み込む
if (preg_match('/^(Ethna_)(.*)(_Test.php)$/', $file_path, $matches)) {
$file_list[] = $full_path;
}
// サブディレクトリがある場合は,再帰的に読み込む.
// "."で始まるディレクトリは読み込まない.
} else {
if (is_dir($full_path) && !preg_match('/^\\./', $file_path, $matches)) {
$file_list = array_merge($file_list, getFileList($full_path));
}
}
}
closedir($dir);
return $file_list;
}
示例4: runProducer
function runProducer()
{
//读取FTP的下载的xml源文件列表
$kmlPath = '/home/webdata/xml';
$xml_file = getFileList($kmlPath);
if (empty($xml_file)) {
echo date('Y-m-d h:i:m') . "XML source files downloaded from the FTP is empty.", PHP_EOF;
exit;
}
sort($xml_file);
$startTime = explode(' ', microtime());
$totalNum = 0;
$i = $n = 1;
foreach ($xml_file as $f) {
//解析文件生成数组
$data = paseXml($f);
//XML格式检查
$res = isFormat($data, $f);
if ($res === false) {
continue;
}
//格式化
$kmldata = formatKmlData($data, $f);
$i++;
$fNum = count($kmldata);
$totalNum += $fNum;
//入队列
$kafkaTime = explode(' ', microtime());
echo $i . '>>>' . $f . ',file count:' . $fNum . ',total:' . $totalNum . "/n";
//备份文件:
// backFile($f);
}
echo 'Total time:' . getTime($startTime) . '/n';
}
示例5: get_imgedit_cache
/**
* 得到编辑图片素材
*
* @param string;
* return array;
*/
function get_imgedit_cache($cache_file, $path)
{
if (!file_exists($cache_file)) {
$data = getFileList($path);
file_put_contents($cache_file, "<?php\n\$data=" . var_export($data, true) . ";\n?>");
//echo 'creat<br>';
return $data;
}
require $cache_file;
return $data;
}
示例6: getFilelist
function getFilelist($dir)
{
global $rFiles;
$files = glob($dir . '/*');
foreach ($files as $f) {
if (is_dir($f)) {
getFileList($f);
continue;
}
$rFiles[] = $f;
}
}
示例7: getIndexFile
function getIndexFile($dir)
{
$files = getFileList($dir);
$indexFile;
foreach ($files as $file) {
if ($file['type'] == "text/html") {
$indexFile = $file['name'];
continue;
}
}
return $indexFile;
}
示例8: getFileList
function getFileList($dir)
{
$files = glob(rtrim($dir, '/') . '/*');
$list = array();
foreach ($files as $file) {
if (is_file($file)) {
$list[] = $file;
}
if (is_dir($file)) {
$list = array_merge($list, getFileList($file));
}
}
return $list;
}
示例9: runConsumer
function runConsumer($topic)
{
$lockfile = '/tmp/mytest.lock';
$startTime = explode(' ', microtime());
$kmlCachePath = getconfig('kmlCachePath');
//本地缓存里存在数据则优先执行
$cacheFiles = getFileList('./cache/' . $topic);
if (!empty($cacheFiles)) {
sort($cacheFiles);
foreach ($cacheFiles as $f) {
$kmls = json_decode(file_get_contents($f));
$items = array_chunk($kmls, 25);
foreach ($items as $item) {
updataKml($item, $startTime, $f, 2, $topic);
}
}
}
// $i = 1;
$f = '';
logs(date('h:i:s', time()) . $topic . ' start ...', 1, 'consumer', $topic);
while ($da = kafka::getInstance()->get($topic)) {
$starttime = explode(' ', microtime());
if (!empty($da->messageList)) {
foreach ($da->messageList as $d) {
$kmls[] = json_decode($d->message);
}
//$i++;
//if($i > 10){
updataKml($kmls, $starttime, $f, 1, $topic);
usleep(10);
logs(date('H:i:s') . 'sleep 10', 1, 'consumer', $topic);
$kmls = [];
/* $i = 1;
}
}else{
if(!empty($kmls)){
updataKml($kmls,$starttime,$f,1, $topic);
}
break;*/
} else {
unlink($lockfile);
logs('success total time:' . getTime($startTime), 1, 'consumer', $topic);
echo 'aa';
exit;
}
}
logs('success total time:' . getTime($startTime), 1, 'consumer', $topic);
unlink($lockfile);
}
示例10: getFileList
function getFileList($dir)
{
$files = glob(rtrim($dir, '/') . '/*html');
$list = array();
foreach ($files as $file) {
if (is_file($file)) {
$list[] = $file;
}
}
$dirs = glob(rtrim($dir, '/') . '/*', GLOB_ONLYDIR);
foreach ($dirs as $d) {
$list = array_merge($list, getFileList($d));
}
return $list;
}
示例11: writePhpList
/**
*
* @param type $oFile
* @param type $sDir
* @param type $sRootPath
*/
function writePhpList($oFile, $sDir, $sRootPath)
{
$aFile = getFileList($sDir);
for ($i = 0; $i < count($aFile); $i++) {
$sTemp = str_replace($sRootPath, ".", $aFile[$i]);
$sTemp = str_replace("\\", "/", $sTemp);
fwrite($oFile, $sTemp . "\n");
}
$aSubDir = getSubDir($sDir);
if ($aSubDir != false) {
for ($i = 0; $i < count($aSubDir); $i++) {
writePhpList($oFile, $aSubDir[$i], $sRootPath);
}
}
}
示例12: writeList
function writeList($dir)
{
$list = getFileList($dir);
if (count($list !== 0)) {
echo "<ol>";
foreach ($list as $value) {
//ファイル名
$fileName = pathinfo($value)["basename"];
// echo $fileName;
if ($fileName === "index.html" || $fileName === "index.php") {
echo "<li><a href='" . $value . "'>" . pathinfo($value)["dirname"] . "</a></li>";
}
}
echo "</ol>";
}
}
示例13: runProducer
function runProducer()
{
$kmlPath = getconfig('kmlPath');
$xml_file = getFileList($kmlPath);
$lockfile = '/tmp/producer.lock';
if (empty($xml_file)) {
logs(date('Y-m-d h:i:m') . "XML source files downloaded from the FTP is empty.");
unlink($lockfile);
exit;
}
sort($xml_file);
$startTime = explode(' ', microtime());
$totalNum = 0;
$i = $n = 1;
foreach ($xml_file as $f) {
//解析文件生成数组
$data = paseXml($f);
//XML格式检查
$res = isFormat($data, $f);
if ($res === false) {
continue;
}
//格式化
$kmldata = formatKmlData($data, $f);
$i++;
$fNum = count($kmldata);
$totalNum += $fNum;
//入队列
$kafkaTime = explode(' ', microtime());
$fileName = basename($f);
insertKafka($kmldata, $fileName);
logs($i . '>>>' . basename($f) . ',file count:' . $fNum . ',total:' . $totalNum . ',into kafka time:' . getTime($kafkaTime));
if ($n > 100) {
usleep(200);
$n = 1;
}
//备份文件:
backFile($f);
}
logs('Total time:' . getTime($startTime));
//unlock();
//$lockfile = '/tmp/producer.lock';
unlink($lockfile);
exit;
}
示例14: getFileList
function getFileList($dir)
{
$files = scandir($dir);
$files = array_filter($files, function ($file) {
return !in_array($file, array('.', '..'));
});
$list = array();
foreach ($files as $file) {
$fullpath = rtrim($dir, '/') . '/' . $file;
if (is_file($fullpath)) {
$list[] = $fullpath;
}
if (is_dir($fullpath)) {
$list = array_merge($list, getFileList($fullpath));
}
}
return $list;
}
示例15: getFileList
function getFileList($root, $basePath = '')
{
$files = [];
$handle = opendir($root);
while (($path = readdir($handle)) !== false) {
if ($path === '.svn' || $path === '.' || $path === '..') {
continue;
}
$fullPath = "{$root}/{$path}";
$relativePath = $basePath === '' ? $path : "{$basePath}/{$path}";
if (is_dir($fullPath)) {
$files = array_merge($files, getFileList($fullPath, $relativePath));
} else {
$files[] = $relativePath;
}
}
closedir($handle);
return $files;
}