示例#1
0
function getFilesInDir($dir, $file_ext = '')
{
    if (!is_dir($dir)) {
        return array();
    }
    $dir = rtrim($dir, '\\/');
    $result = array();
    foreach (glob("{$dir}/*") as $f) {
        if (is_dir($f)) {
            // if is directory
            $result = array_merge($result, getFilesInDir($f, $file_ext));
        } else {
            if ($file_ext && substr($f, -3) != $file_ext) {
                continue;
            }
            $result[] = $f;
        }
    }
    return $result;
}
 /**
  * @param string $language_name
  * @return array|bool
  */
 public function getAllLanguageBlocks($language_name = 'english')
 {
     if (empty($language_name)) {
         $this->error = "Can't get language blocks because language name is empty.";
         return false;
     }
     $result = array('admin' => array(), 'storefront' => array(), 'extensions' => array('admin' => array(), 'storefront' => array()));
     // admin
     $lang_dir = DIR_LANGUAGE . $language_name;
     $xml_files = getFilesInDir($lang_dir, 'xml');
     foreach ($xml_files as $file) {
         $result['admin'][] = str_replace('.xml', '', str_replace($lang_dir . '/', '', $file));
     }
     //storefront
     $lang_dir = DIR_STOREFRONT . 'language/' . $language_name;
     $xml_files = getFilesInDir($lang_dir, 'xml');
     foreach ($xml_files as $file) {
         $result['storefront'][] = str_replace('.xml', '', str_replace($lang_dir . '/', '', $file));
     }
     // extensions
     $extensions_dirs = glob(DIR_EXT . '*', GLOB_ONLYDIR);
     foreach ($extensions_dirs as $extension_dir) {
         //$extension_name = pathinfo($extension_dir,PATHINFO_BASENAME);
         $lang_dir = $extension_dir . '/admin/language/' . $language_name;
         if (is_dir($lang_dir)) {
             $xml_files = getFilesInDir($lang_dir, 'xml');
             foreach ($xml_files as $file) {
                 $result['extensions']['admin'][] = str_replace('.xml', '', str_replace($lang_dir . '/', '', $file));
             }
         }
         $lang_dir = $extension_dir . '/storefront/language/' . $language_name;
         if (is_dir($lang_dir)) {
             $xml_files = getFilesInDir($lang_dir, 'xml');
             foreach ($xml_files as $file) {
                 $result['extensions']['storefront'][] = str_replace('.xml', '', str_replace($lang_dir . '/', '', $file));
             }
         }
     }
     return $result;
 }
?>
">
<title>get files</title>
</head>
<body>
<div>use url parameter 'charset' to specify page charset</div>
<?php 
$doc_root = resetDir($_SERVER["DOCUMENT_ROOT"]);
if ($action == 'child_dir' && !empty($_REQUEST['file'])) {
    $current_path = resetDir($_REQUEST['file']);
} else {
    $current_path = $doc_root;
}
echo '<h2>Current Path:' . $current_path . '</h2>';
//$current_path = preg_replace("/([^\\\]+)\\\{3,}([^\\\]+)/", "$1=$2", $current_path);
$files = getFilesInDir($current_path);
//echo $current_path;exit;
if (count($files) > 0) {
    ?>
	<table width="100%">
	<tr><th style="background:#bbb;" align="left">file name</th>
	<th style="background:#bbb;"  align="left">view source</th>
	<th style="background:#bbb;"  align="left">download</th>
	<th style="background:#bbb;"  align="left">file size</th>
	<th style="background:#bbb;"  align="left">file last date</th>
	<th style="background:#bbb;"  align="left">file path</th>
	<th style="background:#bbb;"  align="left">Action</th>
	</tr>
	
	
	<?php 
示例#4
0
function getImagesInDir($dir)
{
    //  return array_slice(array_merge(getFilesInDir('images', '*.jp*g',false, false), getFilesInDir('images','*.png',false, false)), 0, PRE_CACHE);
    return array_merge(getFilesInDir('images', '*.jp*g', false, false), getFilesInDir('images', '*.png', false, false));
}