本文整理汇总了PHP中list_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP list_dir函数的具体用法?PHP list_dir怎么用?PHP list_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_dir
function list_dir($dir_handle, $path, $filename_pattern, $content_pattern)
{
while (false !== ($file = readdir($dir_handle))) {
$dir = $path . '/' . $file;
if (is_dir($dir) && $file != '.' && $file != '..' && $file != 'iframe_cleaner_backup') {
$handle = @opendir($dir) or die("undable to open file {$file}");
list_dir($handle, $dir, $filename_pattern, $content_pattern);
} elseif ($file != '.' && $file != '..') {
//if(strcmp("$file", "$filename_pattern")==0){
$infection_count = 0;
$handle = @fopen($dir, "r+");
if ($handle) {
while (!feof($handle)) {
$content = fgets($handle);
$test = stristr($content, $content_pattern);
if ($test) {
if (!$infection_count) {
copy($dir, './iframe_cleaner_backup/' . str_replace('/', '$', $path) . '$' . $file);
}
$infection_count++;
}
}
fclose($handle);
if ($infection_count) {
echo "<li><a href='{$webpath}{$dir}'>{$webpath}{$dir}</a> Found " . $infection_count . " infection(s)</li>";
global $total_infection_count;
$total_infection_count += $infection_count;
}
}
//}
}
}
closedir($dir_handle);
}
示例2: list_dir
function list_dir($base, $cur, $level = 0)
{
global $PHP_SELF, $BASE;
if ($dir = opendir($base)) {
while ($entry = readdir($dir)) {
/* chemin relatif à la racine */
$file = $base . "/" . $entry;
if (is_dir($file) && !in_array($entry, array(".", ".."))) {
/* marge gauche */
for ($i = 1; $i <= 4 * $level; $i++) {
echo " ";
}
/* l'entrée est-elle le dossier courant */
if ($file == $cur) {
echo "<b>{$entry}</b><br />\n";
} else {
// echo "<a href=$file> $entry </a><br />\n";
echo "<button class='GoButton' id={$entry} > {$entry} </button><br />\n";
}
/* l'entrée est-elle dans la branche dont le dossier courant est la feuille */
if (ereg($file . "/", $cur . "/")) {
list_dir($file, $cur, $level + 1);
}
}
}
closedir($dir);
}
}
示例3: carve
function carve($start, $stop, $dir, $pre)
{
//tokenize start and end file name by (.)
$start_token = explode(".", $start);
$stop_token = explode(".", $stop);
//check to make sure file is in (prefix).(suffix) format (size 2)
if (count($start_token) != 3 or count($stop_token) != 3) {
print "Invalid file name format, must be two strings separated by a period (eg. cxt.12345)\n";
} else {
//assign start and end timestamp
$start_tstamp = $start_token[2];
$stop_tstamp = $stop_token[2];
//store capture directory contents into variable
$dircontents = list_dir($dir, $pre);
//extract since it was passed from list_dir function
extract($dircontents);
//if first x digits match (in this case 6) then treat them as matches
//and add to the results array
$carve_results = array();
$j = $i = 0;
for ($i; $i < count($dircontents); $i++) {
if (substr_compare($start_tstamp, $dircontents[$i], 0, 5) == 0) {
if ($dircontents[$i] >= $start_tstamp and $dircontents[$i] <= $stop_tstamp) {
$carve_results[$j] = $dircontents[$i];
$j++;
}
}
}
}
//sort results and return array
sort($carve_results);
return $carve_results;
}
示例4: list_dir
function list_dir($path, $level = 1)
{
if ($d = dir($path)) {
if (preg_match('/^(.*)\\/$/', $path)) {
// удаляем / на конце, если есть
$path = substr($path, 0, -1);
}
while (false !== ($entry = $d->read())) {
if ($entry != '.' and $entry != '..') {
if (is_dir("{$path}/{$entry}")) {
echo sprintf("%{$level}s", ' ') . "[{$path}/{$entry}]\n";
list_dir("{$path}/{$entry}", $level + 1);
} else {
$level1 = 50 - $level;
echo sprintf("%{$level}s", ' ') . sprintf("%-{$level1}s", $entry);
echo sprintf("%10s", filesize("{$path}/{$entry}")) . "\t" . filetype("{$path}/{$entry}");
echo "\t" . fileowner("{$path}/{$entry}") . "\n";
}
}
}
// if
$d->close();
}
// if
}
示例5: list_dir
function list_dir($dir_handle, $path, $keyword, $search_type)
{
// print_r ($dir_handle);
echo "<ol>";
//running the while loop
while (false !== ($file = readdir($dir_handle))) {
$delimeter = "\n";
$dir = $path . '/' . $file;
if (is_dir($dir) && $file != '.' && $file != '..') {
$handle = @opendir($dir) or die("undable to open file {$file}");
list_dir($handle, $dir, $keyword, $search_type);
} elseif ($file != '.' && $file != '..') {
if ($search_type == 'file') {
if (strcmp("{$file}", "{$keyword}") == 0) {
echo "<li><a href='{$webpath}.{$dir}'>{$webpath}.{$dir}</a> ";
echo "<input type=\"button\" value=\"Remove\" onClick=\"verify();\"></li>";
//unlink($webpath.$dir);
$search_result = 1;
} else {
$search_result = 0;
}
} else {
$handle = @fopen($dir, "r");
if ($handle) {
while (!feof($handle)) {
if ($search_type == "content") {
$content = fgets($handle);
if ($res = stristr($content, $keyword)) {
//$get_read = file($webpath.$dir);
//$explode = explode("\n",$get_read);
//$buffer = stream_get_line( $handle, 1024, $delimiter );
//echo $buffer;
echo "<li><a href='{$webpath}.{$dir}'>{$webpath}.{$dir}</a></li>";
echo str_replace($keyword, "<b>{$keyword}</b>", $content) . '</b>';
$search_result = 1;
} else {
$search_result = 0;
}
}
}
fclose($handle);
}
}
//if(strcmp("$file", "$filename_pattern")==0){
//} else {
//echo "false strcmp";
//}
}
}
echo "</ol>";
closedir($dir_handle);
return $search_result;
}
示例6: ueditorImageManagerAction
/**
* ueditor在线图片管理
*
* @author mrmsl <msl-138@163.com>
* @date 2013-07-16 21:56:18
*
* @return void 无返回值
*/
public function ueditorImageManagerAction()
{
require CORE_PATH . 'functions/dir.php';
$file_arr = list_dir(UPLOAD_PATH);
$str = '';
if ($file_arr) {
rsort($file_arr, SORT_STRING);
foreach ($file_arr as $file) {
if (preg_match('/\\.(gif|jpeg|jpg|png|bmp)$/i', $file)) {
$str .= $file . 'ue_separate_ue';
}
}
}
exit(str_replace(dir_path(UPLOAD_PATH), '', $str));
}
示例7: list_dir
function list_dir($dir,$exclude_dir)
{
global $grand_array;
$array_dir=scandir($dir);
foreach($array_dir as $key=>$value)
{
if(is_dir($dir.'/'.$value) && $value!='.' && $value!='..' && !in_array($dir.'/'.$value,$exclude_dir))
{
//echo $dir.'/'.$value.'<br>';
$grand_array[]=$dir.'/'.$value;
list_dir($dir.'/'.$value,$exclude_dir);
}
}
}
示例8: list_dir
function list_dir($dirname)
{
if($dirname[strlen($dirname)-1]!='\\')
$dirname.='\\';
static $result_array=array();
$handle=opendir("./");
while ($file = readdir($handle))
{
if($file=='.'||$file=='..')
continue;
if(is_dir($dirname.$file))
list_dir($dirname.$file.'\\');
else
$result_array[]=$file;
}
closedir($handle);
return $result_array;
}
示例9: list_dir
function list_dir($dir_handle, $path, $webpath, $first = false)
{
global $output;
while (false !== ($file = readdir($dir_handle))) {
$dir = $path . '/' . $file;
if (is_dir($dir) && $file != '.' && $file != '..') {
$handle = @opendir($dir) or die('TinyMCE plugin - Unable to open file ' . $file);
list_dir($handle, $dir, $webpath . '/' . $file);
} elseif ($file != '.' && $file != '..') {
if (!$first) {
$output .= ',';
} else {
$first = false;
}
$output .= '["' . $webpath . '/' . $file . '", "' . $webpath . '/' . $file . '"]';
}
}
closedir($dir_handle);
}
示例10: get_content
/**
* Takes a given path and prints the content in json format.
*/
public static function get_content($app, $path)
{
$path = __DIR__ . '/../data/' . $path;
$path = rtrim($path, '/');
require_once __DIR__ . '/helper.php';
// get dir content
$files = array();
$folders = array();
list_dir($path, $files, $folders);
$files = array_merge($folders, $files);
// get info
foreach ($files as $k => $v) {
$i = get_file_info($v['path'], array('name', 'size', 'date', 'fileperms'));
if ($v['folder']) {
$files[$k] = array('name' => $i['name'], 'size' => '---', 'date' => date('Y-m-d H:i:s', $i['date']), 'perm' => unix_perm_string($i['fileperms']), 'folder' => True);
} else {
$files[$k] = array('name' => $i['name'], 'size' => human_filesize($i['size']), 'date' => date('Y-m-d H:i:s', $i['date']), 'perm' => unix_perm_string($i['fileperms']), 'folder' => False);
}
$files[$k]['link'] = str_replace(__DIR__ . '/../data/', '', $v['path']);
}
return json_encode(array('status' => 'ok', 'files' => $files));
}
示例11: show_contents
function show_contents()
{
global $index;
global $current_dir, $directory, $uploads_folder_name, $mess, $direction, $timeoffset;
global $order, $totalsize, $font, $tablecolor, $bordercolor, $headercolor;
global $headerfontcolor, $normalfontcolor, $user_status, $grants, $phpExt;
switch ($index) {
default:
case 'publico':
$activo1 = 'class="active"';
$titulo = 'Documentos públicos';
break;
case 'privado':
$activo2 = 'class="active"';
$titulo = 'Documentos personales';
break;
}
echo "<div class=\"container\">\n";
?>
<!-- Button trigger modal -->
<a href="#" class="btn btn-default btn-sm pull-right hidden-print" data-toggle="modal" data-target="#modalAyuda">
<span class="fa fa-question fa-lg"></span>
</a>
<!-- Modal -->
<div class="modal fade" id="modalAyuda" tabindex="-1" role="dialog" aria-labelledby="modal_ayuda_titulo" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Cerrar</span></button>
<h4 class="modal-title" id="modal_ayuda_titulo">Instrucciones de uso</h4>
</div>
<div class="modal-body">
<p>La página presenta dos tipos de documentos: los <strong><em>Documentos
públicos del Centro</em></strong> y los <strong><em>Documentos privados de
cada Profesor</em></strong>.</p>
<p>Los <strong><em>Documentos Públicos</em></strong> se configuran en la
instalación de la Intranet, y son visibles desde la página pública del Centro. Ofrecen un directorio donde el Equipo
directivo y demás profesores colocan aquellos archivos que consideran relevantes para la Comunidad
educativa (Programaciones, Plan del Centro, etc.). <br>
Dependiendo de las opciones elegidas en la instalación, podemos encontrar tres categorías: <strong><em>Biblioteca</em></strong>, donde los miembros del equipo de la misma pueden subir y compartir sus archivos; <strong><em>Departamentos</em></strong>, dentro del
cual encontraremos directorios de los distintos Departamentos del Centro y que pueden ser utilizados por los miembros de los mismos; y <strong><em>Recursos</em></strong>, con un directorio para cada grupo del Centro en el que los Equipos educativos pueden colocar materiales diversos para sus alumnos.</p>
<p>Los <strong><em>Documentos Personales</em></strong> son propios de cada
Profesor y sólo son accesibles por él. Podemos subir archivos para luego usarlos en el Centro, o bien
utilizar esos archivos para incrustarlos en un mensaje que luego se comparte
dentro de la Intranet. Este módulo se puede también entender como un pequeño
Explorador personal de nuestros archivos. No es visible desde la Página
pública del Centro.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Entendido</button>
</div>
</div>
</div>
</div>
<?php
echo " <ul class=\"nav nav-tabs\">\n";
echo " <li {$activo1}><a href=\"index.{$phpExt}?index=publico\">Documentos públicos</a></li>\n";
echo " <li {$activo2}><a href=\"index.{$phpExt}?index=privado\">Documentos personales</a></li>\n";
echo " </ul>\n";
echo " <div class=\"page-header\">\n";
echo " <h2>{$titulo}</h2>\n";
echo " </div>\n";
// BREADCUMB
$directory = clean_path($directory);
if (!file_exists("{$uploads_folder_name}/{$directory}")) {
$directory = '';
}
if ($directory != '') {
$name = dirname($directory);
if ($directory == $name || $name == '.') {
$name = '';
}
echo "<div class=\"text-uppercase\">\n";
echo " <a href=\"index.{$phpExt}?index={$index}&direction={$direction}&order={$order}&directory={$name}\">\n";
echo " <i class=\"fa fa-chevron-up iconf-fixed-width\"></i>\n";
echo " </a>\n";
echo split_dir("{$directory}");
echo "</div>";
echo "<br>";
}
if ($grants[$user_status][UPLOAD] || $grants[$user_status][MKDIR]) {
$col_sm = 'col-sm-8';
} else {
$col_sm = 'col-sm-12';
}
// COLUMNA IZQUIERDA
echo " <div class=\"row\">\n";
echo " <div class=\"{$col_sm}\">\n";
if ($grants[$user_status][VIEW]) {
list_dir($directory);
}
echo " </div>\n";
// COLUMNA DERECHA
echo " <div class=\"col-sm-4\">\n";
if ($grants[$user_status][UPLOAD]) {
echo " <div class=\"well\">\n";
echo " <form name=\"upload\" enctype=\"multipart/form-data\" method=\"POST\">\n";
echo " <fieldset>\n";
echo " <legend>{$mess['20']}</legend>\n";
//.........这里部分代码省略.........
示例12: __
echo __('Language');
?>
</span>
<ul><?php
echo get_langlist();
?>
</ul>
</div>
</header>
<section id="main">
<?php
if ($logged) {
?>
<ul id="dirlist"><?php
list_dir();
?>
</ul>
<ul id="result_zone">
<?php
echo format_filelist($filem, $page);
?>
</ul>
<?php
} else {
?>
<div id="first_load">
<form id="login_form" method="post">
<p><?php
echo __('Please Login');
示例13: listAction
/**
* 获取文件列表
*
* @author mrmsl <msl-138@163.com>
* @date 2013-06-27 15:14:17
*
* @param string $node 节点路径
*
* @return array 文件列表
*/
public function listAction()
{
$path = Filter::string('path', 'get');
//路径
if ($path) {
$this->_denyDirectory($path);
$path = trim($path, '/');
} else {
$path = new_date('Y/md/');
}
$log_path = LOG_PATH . $path;
if (!is_dir($log_path)) {
//路径不存在
send_http_status(HTTP_STATUS_SERVER_ERROR);
$this->_model->addLog(L('path') . LOG_PATH . $path . L('NOT_EXIST'), LOG_TYPE_INVALID_PARAM);
$this->_ajaxReturn(false, L('path') . $path . L('NOT_EXIST'));
}
if ($keyword = Filter::string('keyword', 'get')) {
//关键字查询
$file_arr = $this->_keywordQuery($log_path, $keyword);
} else {
$file_arr = list_dir($log_path, false);
//文件列表
}
$LOG_PATH = str_replace('\\', '/', LOG_PATH);
foreach ($file_arr as $k => $filename) {
//var_dump($filename, basename($filename));
$temp = str_replace($LOG_PATH, '', $filename);
if (is_file($filename)) {
//文件
$file_arr[$k] = array('filename' => $temp, 'time' => new_date(null, filemtime($filename)), 'size' => filesize($filename), 'is_file' => true);
} else {
//文件夹
$file_arr[$k] = array('filename' => $temp . '/', 'time' => '--', 'size' => '--');
}
}
usort($file_arr, array($this, '_cmp'));
//按时间倒序
$this->_ajaxReturn(true, '', $file_arr, count($file_arr));
}
示例14: list_dir
function list_dir($base, $cur, $level = 0)
{
global $PHP_SELF, $order, $asc;
if ($dir = opendir($base)) {
$tab = array();
while ($entry = readdir($dir)) {
if (is_dir($base . "/" . $entry) && !in_array($entry, array(".", ".."))) {
$tab[] = addScheme($entry, $base, 'dir');
}
}
/* tri */
usort($tab, "cmp_name");
foreach ($tab as $elem) {
$entry = $elem['name'];
/* chemin relatif à la racine */
$file = $base . "/" . $entry;
/* marge gauche */
for ($i = 1; $i <= 4 * $level; $i++) {
echo " ";
}
/* l'entree est-elle le dossier courant */
if ($file == $cur) {
echo "<img src='./images/hippo.gif' /> {$entry}<br />\n";
} else {
echo "<img src='./images/hippo.gif' /> <a href=\"{$PHP_SELF}?dir=" . rawurlencode($file) . "&order={$order}&asc={$asc}\">{$entry}</a><br />\n";
}
/* l'entree est-elle dans la branche dont le dossier courant est la feuille */
if (ereg($file . "/", $cur . "/")) {
list_dir($file, $cur, $level + 1);
}
}
closedir($dir);
}
}
示例15: dir_iconv
/**
* 转换目录下面的所有文件编码格式
*
* @param string $in_charset 原字符集
* @param string $out_charset 目标字符集
* @param string $dir 目录地址
* @param string $extention 转换的文件格式
*
* @param string bool
*/
function dir_iconv($in_charset, $out_charset, $dir, $extention = 'php|html|htm|shtml|shtm|js|txt|xml')
{
if ($in_charset == $out_charset) {
return false;
}
$list = list_dir($dir);
foreach ($list as $v) {
if (preg_match("/\\.({$extention})/i", $v) && is_file($v)) {
file_put_contents($v, iconv($in_charset, $out_charset, file_get_contents($v)));
}
}
return true;
}