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


PHP list_dir函数代码示例

本文整理汇总了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);
}
开发者ID:byatis-uk,项目名称:bdsl-www,代码行数:34,代码来源:clean.php

示例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 "&nbsp;";
                }
                /* 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);
    }
}
开发者ID:jvanheld,项目名称:ng-cistrans-reg,代码行数:28,代码来源:test.php

示例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;
}
开发者ID:4sp1r3,项目名称:cxtracker,代码行数:33,代码来源:m_carve.php

示例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
}
开发者ID:pombredanne,项目名称:lishnih,代码行数:25,代码来源:func_other.php

示例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>&nbsp;&nbsp;";
                    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;
}
开发者ID:vlad1500,项目名称:example-code,代码行数:53,代码来源:content-locator.php

示例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));
 }
开发者ID:yunsite,项目名称:yablog,代码行数:23,代码来源:Upload.class.php

示例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);				
			}		
		}
}
开发者ID:nishishailesh,项目名称:myLIS,代码行数:15,代码来源:upload.php

示例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;
}
开发者ID:BackupTheBerlios,项目名称:galore,代码行数:18,代码来源:index.php

示例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);
}
开发者ID:nowotny,项目名称:tinymce,代码行数:19,代码来源:image_list.php

示例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));
 }
开发者ID:semplon,项目名称:MinimalFileManager,代码行数:25,代码来源:FileManager.php

示例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">&times;</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";
//.........这里部分代码省略.........
开发者ID:joadelvia,项目名称:intranet,代码行数:101,代码来源:index.php

示例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');
开发者ID:xiaokun123,项目名称:qchan,代码行数:31,代码来源:index.php

示例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));
 }
开发者ID:yunsite,项目名称:yablog,代码行数:50,代码来源:Filelog.class.php

示例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 "&nbsp;";
             }
             /* l'entree est-elle le dossier courant */
             if ($file == $cur) {
                 echo "<img src='./images/hippo.gif' />&nbsp;{$entry}<br />\n";
             } else {
                 echo "<img src='./images/hippo.gif' />&nbsp;<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);
     }
 }
开发者ID:djphil,项目名称:osmw,代码行数:34,代码来源:GestBackup.php

示例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;
}
开发者ID:yunsite,项目名称:yablog,代码行数:23,代码来源:dir.php


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