本文整理汇总了PHP中listFiles函数的典型用法代码示例。如果您正苦于以下问题:PHP listFiles函数的具体用法?PHP listFiles怎么用?PHP listFiles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listFiles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listFiles
function listFiles($path, $prefix = '', $sublist = false, $pathName = '')
{
if (empty($path) || !is_readable($path) || !($files = scandir($path)) || empty($files)) {
return;
}
if ($sublist) {
$eid = strtr(trim($path, "/"), "/", "-");
echo "{$prefix}<li class='sublist'>\n";
echo "{$prefix}<span class='dir closed' rel='{$eid}'>{$pathName}/</span><ul class='directory' id='{$eid}'>\n";
} else {
echo "<ul id='listRoot' class='dirlist'>\n";
}
sort($files, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($files as $f) {
if ($f == '.' || $f == '..') {
continue;
}
// ignore . and ..
if (is_dir($fpath = rtrim($path, '/') . '/' . $f)) {
listFiles($fpath, $prefix . "\t", true, $f);
} else {
echo "{$prefix}\t<li>{$f}</li>\n";
}
}
echo "{$prefix}</ul>\n";
if ($sublist) {
echo "{$prefix}</li>\n";
}
}
示例2: listFiles
function listFiles($dir, $keyword, &$array)
{
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
//if it is a directory, then continue
if (is_dir("{$dir}/{$file}")) {
listFiles("{$dir}/{$file}", $keyword, $array);
} else {
$data = fread(fopen("{$dir}/{$file}", "r"), filesize("{$dir}/{$file}"));
//read file
if (stristr("<body([^>]+)>(.+)</body>", $data, $b)) {
$body = strip_tags($b["2"]);
} else {
$body = strip_tags($data);
}
if ($file != "glug_search.php") {
if (stristr("{$keyword}", $body)) {
if (stristr("<title>(.+)</title>", $data, $m)) {
$title = $m["1"];
} else {
$title = "no title";
}
$array[] = "{$dir}/{$file} {$title}";
}
}
}
}
}
}
示例3: listFiles
function listFiles($dir, &$result = array())
{
if (is_dir($dir)) {
$thisdir = dir($dir);
while ($entry = $thisdir->read()) {
if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.') {
$isFile = is_file("{$dir}/{$entry}");
$isDir = is_dir("{$dir}/{$entry}");
if ($isDir) {
listFiles("{$dir}/{$entry}", $result);
} elseif ($isFile) {
$result[] = "{$dir}/{$entry}";
}
}
}
}
}
示例4: list_posts
function list_posts($cfg)
{
require_once 'inc/simplepie.inc';
$feed = new SimplePie();
// Set which feed to process.
// handle the different feeds
// blogging
if ($cfg['tumblr'] != "") {
$feeds[] = 'http://' . $cfg['tumblr'] . '.tumblr.com/rss';
}
if ($cfg['blogger'] != "") {
$feeds[] = 'http://' . $cfg['blogger'] . '.blogspot.com/feeds/posts/default?alt=rss';
}
if ($cfg['medium'] != "") {
$feeds[] = 'https://medium.com/feed/@' . $cfg['medium'] . '/';
}
if ($cfg['ghost'] != "") {
$feeds[] = 'http://' . $cfg['ghost'] . '.ghost.io/rss/';
}
if ($cfg['postachio'] != "") {
$feeds[] = 'http://' . $cfg['postachio'] . '.postach.io/feed.xml';
}
if ($cfg['custom'] != "") {
$feeds[] = $cfg['custom'];
}
// plugins
if (file_exists('plugins')) {
$plugins = listFiles('plugins');
if (count($plugins) > 0) {
foreach ($plugins as $plugin) {
$feeds[] = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/plugins/' . $plugin . '/index.php';
}
}
}
$feed->set_feed_url($feeds);
// allow iframe embeds
$strip_htmltags = $feed->strip_htmltags;
array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);
$feed->strip_htmltags($strip_htmltags);
// Run SimplePie.
$feed->init();
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
return $feed;
}
示例5: listFiles
function listFiles($path, &$tabFics, $root = '')
{
$result = true;
$path = rtrim($path, '/') . '/';
$handle = opendir($path);
for (; false !== ($file = readdir($handle));) {
if ($file != "." and $file != "..") {
$fullpath = $path . $file;
if (is_dir($fullpath)) {
listFiles($fullpath, $tabFics, $root . $file . '/');
} else {
$tabFics[] = $root . $file;
}
}
}
closedir($handle);
return true;
}
示例6: listFiles
function listFiles($dir = '', $skip_files = null, $recursive = false, $only_directories = false)
{
if (empty($dir) || !is_dir($dir)) {
return false;
}
$file_list = array();
if (!($handle = @opendir($dir))) {
return false;
}
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_file($dir . '/' . $file)) {
if ($only_directories) {
continue;
}
if (empty($skip_files)) {
$file_list[] = $file;
continue;
}
if (!empty($skip_files)) {
if (is_array($skip_files) && !in_array($file, $skip_files)) {
$file_list[] = $file;
}
if (!is_array($skip_files) && $file != $skip_files) {
$file_list[] = $file;
}
}
continue;
}
if (is_dir($dir . '/' . $file) && !isset($file_list[$file])) {
if ($recursive) {
$file_list[$file] = listFiles($dir . '/' . $file, $skip_files, $recursive, $only_directories);
}
}
}
closedir($handle);
if (!$recursive) {
natcasesort($file_list);
}
return $file_list;
}
示例7: recursive_copy
function recursive_copy($source, $destination)
{
$counter = 0;
if (substr($source, strlen($source), 1) != "/") {
$source .= "/";
}
if (substr($destination, strlen($destination), 1) != "/") {
$destination .= "/";
}
if (!is_dir($destination)) {
makeDirs($destination);
}
$itens = listFiles($source);
foreach ($itens as $id => $name) {
if ($name[0] == "/") {
$name = substr($name, 1);
}
if (is_file($source . $name)) {
// file
if ($name != "Thumbs.db") {
$counter++;
if (!copy($source . $name, $destination . $name)) {
echo "Error: " . $source . $name . " -> " . $destination . $name . "<br/>";
} else {
safe_chmod($destination . $name, 0775);
}
} else {
@unlink($source . $name);
}
} else {
if (is_dir($source . $name)) {
// dir
if (!is_dir($destination . $name)) {
safe_mkdir($destination . $name);
}
$counter += recursive_copy($source . $name, $destination . $name);
}
}
}
return $counter;
}
示例8: onCron
function onCron($isDay = false)
{
# cron Triggered, isDay or isHour
###### -> Construct should add this module to the onCron array
if ($isDay) {
// delete week old entries (select data, detect files, delete files, delete data)
$core =& $this->parent;
$undoModule = $this->parent->loaded($this->moduleRelation);
$sql = "SELECT id, files FROM " . $undoModule->dbname . " WHERE files<>'' AND data<NOW() - INTERVAL 1 WEEK";
$core->dbo->query($sql, $r, $n);
if ($n > 0) {
for ($c = 0; $c < $n; $c++) {
list($id, $files) = $core->dbo->fetch_row($r);
$files = @unserialize($files);
if ($files) {
foreach ($files as $file) {
if (is_file(CONS_FMANAGER . "_undodata/" . $file)) {
@unlink(CONS_FMANAGER . "_undodata/" . $file);
}
}
}
}
}
$core->dbo->simpleQuery("DELETE FROM " . $undoModule->dbname . " WHERE data<NOW() - INTERVAL 1 WEEK");
# Find orphan files and delete them
$lastWeek = date("Y-m-d") . " 00:00:00";
$lastWeek = datecalc($lastWeek, 0, 0, -7);
$lastWeek = tomktime($lastWeek);
$files = listFiles(CONS_FMANAGER . "_undodata/", '@^(.*)$@', true);
foreach ($files as $file) {
$ft = filemtime(CONS_FMANAGER . "_undodata/" . $file);
if ($ft < $lastWeek) {
@unlink(CONS_FMANAGER . "_undodata/" . $file);
} else {
break;
}
// the list is ordered by date, so the first not to match means none will
}
}
}
示例9: locateAnyFile
function locateAnyFile(&$arquivo, &$ext, $extensionsToSearch = "")
{
# locate ANY file with the mentioned name. Slow and resource intence.
if ($extensionsToSearch != "") {
$v = locateFile($arquivo, $ext, $extensionsToSearch);
# fallback to locateFile
return $v;
}
$dir = explode("/", $arquivo);
$filename = array_pop($dir);
// tira arquivo
$dir = implode("/", $dir);
$filename = str_replace("-", "\\-", $filename);
$arquivos = listFiles($dir, '@^' . $filename . '(\\.)(.+)$@i', false, true);
if (count($arquivos) > 0) {
$ext = explode(".", $arquivos[0]);
$ext = array_pop($ext);
$arquivo .= "." . $ext;
return true;
}
return false;
}
示例10: listFiles
<?php
$folder = $_GET['folder'];
function listFiles($relativePath)
{
$files1 = scandir($relativePath);
return json_encode($files1);
}
header('Content-Type: application/json');
echo listFiles("../Music/" . $folder);
示例11: array_merge
if (isDir($filepath)) {
$files = array_merge($files, listdir($filepath));
} else {
array_push($files, $filepath);
}
}
closedir($fh);
} else {
# false if the function was called with an invalid non-directory argument
$files = false;
}
return $files;
}
//------------- begin main-----------------
//-----
$files = listFiles('.');
//$files = listdir('.');
//print_r($files);
foreach ($files as $fil) {
//check for file in database
$end = substr($fil, -4);
// also count underscores in filename
$numsep = substr_count($fil, "_");
// quick check of filename
if ($end == '.tif') {
// make array with the period as delimiter
$allstr = explode("_", $fil);
// build dir name according to numsep
if ($numsep == 2 || $numsep == 3) {
// three part name- dir must be parts 1,2
$dirname = $allstr[0] . "_" . $allstr[1];
示例12: listFiles
function listFiles($dir)
{
$files = array();
$lista = glob($dir . '/*');
foreach ($lista as $valor) {
if (is_dir($valor)) {
$inner_files = listFiles($valor);
if (is_array($inner_files)) {
$files = array_merge($files, $inner_files);
}
}
if (is_file($valor)) {
array_push($files, $valor);
}
}
return $files;
}
示例13: edit_parse
function edit_parse($action, &$data)
{
$baseModule = $this->parent->loaded($this->moduleRelation);
if ($action != CONS_ACTION_DELETE) {
# you cannot ADD or CHANGE a group with higher level than you
if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) {
if (isset($data['level']) && $data['level'] >= $_SESSION[CONS_SESSION_ACCESS_LEVEL]) {
$this->parent->log[] = $this->parent->langOut("group_cannot_change_higher");
$this->parent->setLog(CONS_LOGGING_WARNING);
return false;
} else {
if (isset($data['level']) && $data['level'] >= 100) {
# you cannot add a level 100+ group (only manually)
$this->parent->log[] = $this->parent->langOut("group_top_level_is_99");
$this->parent->setLog(CONS_LOGGING_WARNING);
if ($action == CONS_ACTION_INCLUDE) {
$data['level'] = 99;
} else {
unset($data['level']);
}
}
}
} else {
if ($action == CONS_ACTION_UPDATE) {
$lvl = $this->parent->dbo->fetch("SELECT level FROM " . $baseModule->dbname . " WHERE id=" . $data['id']);
if ($lvl == 100 && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) {
$this->parent->log[] = $this->parent->langOut("cannot_change_master_group");
$this->parent->setLog(CONS_LOGGING_WARNING);
return false;
}
if ($data['id'] == $this->parent->dimconfig['guest_group'] && isset($data['level']) && $data['level'] > 0) {
$this->parent->log[] = $this->parent->langOut("cannot_change_guest_level");
$this->parent->setLog(CONS_LOGGING_WARNING);
$data['level'] = 0;
}
}
}
if (isset($data['level']) && $data['level'] >= 100 && $_SESSION[CONS_SESSION_ACCESS_LEVEL] != 100) {
# only masters can set 100
$this->parent->log[] = $this->parent->langOut("group_top_level_is_99");
$this->parent->setLog(CONS_LOGGING_WARNING);
$data['level'] = 99;
}
} else {
if ($action == CONS_ACTION_DELETE && $this->parent->safety) {
# gets the group level, if it's higher, disallow delete
$lvl = $this->parent->dbo->fetch("SELECT level FROM " . $baseModule->dbname . " WHERE id=" . $data['id']);
if ($lvl >= $_SESSION[CONS_SESSION_ACCESS_LEVEL]) {
$this->parent->log[] = $this->parent->langOut("group_cannot_change_higher");
$this->parent->setLog(CONS_LOGGING_WARNING);
return false;
}
if ($data['id'] == $this->parent->dimconfig['guest_group']) {
$this->parent->log[] = $this->parent->langOut("group_cannot_delete_guest");
$this->parent->setLog(CONS_LOGGING_WARNING);
return false;
}
}
}
// delete all caches
$files = listFiles(CONS_PATH_CACHE . $_SESSION['CODE'] . "/", $eregfilter = '@admin([0-9]*)\\.cache@');
foreach ($files as $file) {
@unlink(CONS_PATH_CACHE . $_SESSION['CODE'] . "/" . $file);
}
return true;
}
示例14: importer
function importer()
{
$htmlIMG = $_REQUEST['imgpath'];
$cssIMG = $_REQUEST['cssimgpath'];
// improves/fix css, in and out
$cssFiles = listFiles(CONS_PATH_PAGES . $_SESSION["CODE"] . "/files/", '/^.*\\.css$/i');
foreach ($cssFiles as $cF) {
$css = cReadFile(CONS_PATH_PAGES . $_SESSION["CODE"] . "/files/" . $cF);
$css = str_replace($cssIMG, "", $css);
$css = str_replace(" ", "\t", $css);
cWriteFile(CONS_PATH_PAGES . $_SESSION["CODE"] . "/files/" . $cF, $css);
}
// improves/fix html, in
$htmlFiles = listFiles(CONS_PATH_PAGES . $_SESSION["CODE"] . "/template/", '/^([^_]).*\\.html$/i');
$htmlSTR = array();
$cut = array();
foreach ($htmlFiles as $hF) {
$htmlSTR[$hF] = cReadFile(CONS_PATH_PAGES . $_SESSION["CODE"] . "/template/" . $hF);
$htmlSTR[$hF] = str_replace($htmlIMG, "{IMG_PATH}", $htmlSTR[$hF]);
$htmlSTR[$hF] = str_replace(" ", "\t", $htmlSTR[$hF]);
$bodyPos = strpos($htmlSTR[$hF], "<body>");
if ($bodyPos !== false) {
$htmlSTR[$hF] = substr($htmlSTR[$hF], $bodyPos + 6);
$htmlSTR[$hF] = str_replace("</body>", "", $htmlSTR[$hF]);
} else {
$bodyPos = strpos($htmlSTR[$hF], "<body");
if ($bodyPos !== false && $bodyPos != 0) {
$htmlSTR[$hF] = substr($htmlSTR[$hF], $bodyPos - 1);
}
}
$htmlSTR[$hF] = str_replace("</html>", "", $htmlSTR[$hF]);
cWriteFile(CONS_PATH_PAGES . $_SESSION["CODE"] . "/template/" . $hF . ".out", $htmlSTR[$hF]);
}
// locate patterns within the files, using index.html
//{CORE_DEBUG} {FRAME_CONTENT}
echo "css replaced, html outputed as .out, frame breaking not implemented";
#TODO:
die;
}
示例15: listFiles
function listFiles($dir)
{
global $aas_cpath;
$ffs = scandir($dir);
$downloads_folder = substr(DIR_FS_DOWNLOAD, strlen(DIR_FS_CATALOG));
echo '<ol style="margin-left:5px;">';
foreach ($ffs as $ff) {
if ($ff != '.' && $ff != '..' && $ff != '.htaccess') {
echo '<li class="downloadable_filename_li">';
if (is_file($dir . '/' . $ff)) {
$fs = substr($dir . '/' . $ff, strlen(DIR_FS_DOWNLOAD));
echo '<label><input type="radio" name="dowloadable_filename" class="dowloadable_filename" value="' . $fs . '">' . $downloads_folder . '<strong style="color:green">' . $fs . '</strong></label>';
} elseif (is_dir($dir . '/' . $ff)) {
listFiles($dir . '/' . $ff);
echo '</li>';
}
}
}
echo '</ol>';
}