示例#1
0
function count_dir($dir_handle, $path)
{
    global $foldercount, $phpcount, $htmlcount, $csscount, $othercount;
    global $phplinecount, $htmllinecount, $csslinecount;
    //echo "<ol>";
    while (false !== ($file = readdir($dir_handle))) {
        $dir = $path . '/' . $file;
        if (is_dir($dir) && $file != '.' && $file != '..') {
            $handle = @opendir($dir) or die("undable to open file {$file}");
            //echo "<li>$file</li>";
            $foldercount++;
            count_dir($handle, $dir);
        } elseif ($file != '.' && $file != '..') {
            $fileext = strstr_after($file, '.');
            switch ($fileext) {
                case "html":
                    $htmlcount++;
                    $htmllinecount = $htmllinecount + count_lines($dir);
                    //echo "<li>$file</li>";
                    break;
                case "htm":
                    $htmlcount++;
                    $htmllinecount = $htmllinecount + count_lines($dir);
                    //echo "<li>$file</li>";
                    break;
                case "php":
                    $phpcount++;
                    $phplinecount = $phplinecount + count_lines($dir);
                    //echo "<li>$file</li>";
                    break;
                case "css":
                    $csscount++;
                    $csslinecount = $csslinecount + count_lines($dir);
                    //echo "<li>$file</li>";
                    break;
                default:
                    $othercount++;
                    break;
            }
        }
    }
    //echo "</ol>";
    //closing the directory
    closedir($dir_handle);
}
function count_dir($dir, $totalsize = 0)
{
    $dir = $dir . '/';
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (is_dir($dir . $file)) {
            $totalsize = count_dir($dir . $file, $totalsize);
        } else {
            $totalsize++;
        }
    }
    closedir($handle);
    return $totalsize;
}
示例#3
0
    echo $lang->phrase('admin_design_directory');
    ?>
</td>
   <td class="ubox" width="10%"><?php 
    echo $lang->phrase('admin_design_files');
    ?>
</td>
   <td class="ubox" width="40%"><?php 
    echo $lang->phrase('admin_design_action');
    ?>
</td>
  </tr>
  <?php 
    while (false !== ($entry = $d->read())) {
        if ($entry != '..' && $entry != '.' && preg_match('/^\\d{1,}$/', $entry) && is_dir($dir . $entry)) {
            $files = count_dir($dir . $entry);
            ?>
  <tr>
   <td class="mbox"><?php 
            echo $entry;
            ?>
</td>
   <td class="mbox" align="right"><?php 
            echo $files;
            ?>
</td>
   <td class="mbox">
   <a class="button" href="admin.php?action=explorer&path=<?php 
            echo urlencode('./images/' . $entry . '/');
            ?>
"><?php 
示例#4
0
/**
 * This function displays the number of files contained in a directory
 *
 * @param   string the path of the directory
 * @param   boolean true if we want the total quantity of files
 * include in others child directories, false only  files in the directory
 * @return  array the first element is an integer with the number of files
 * in the folder, the second element is the number of directories
 * @author  Julio Montoya
 * @version April 2008
 */
function count_dir($path_dir, $recurse)
{
    $count = 0;
    $count_dir = 0;
    $d = dir($path_dir);
    while ($entry = $d->Read()) {
        if (!(($entry == '..') || ($entry == '.'))) {
            if (is_dir($path_dir.'/'.$entry)) {
                $count_dir++;
                if ($recurse) {
                    $count += count_dir($path_dir . '/' . $entry, $recurse);
                }
            } else {
                $count++;
            }
        }
    }
    $return_array = array();
    $return_array[] = $count;
    $return_array[] = $count_dir;
    return $return_array;
}