當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。