Example #1
0
function getdirsize($dir)
{
    $dirlist = opendir($dir);
    while (false !== ($folderorfile = readdir($dirlist))) {
        if ($folderorfile != "." && $folderorfile != "..") {
            if (is_dir("{$dir}/{$folderorfile}")) {
                $dirsize += getdirsize("{$dir}/{$folderorfile}");
            } else {
                $dirsize += filesize("{$dir}/{$folderorfile}");
            }
        }
    }
    closedir($dirlist);
    return $dirsize;
}
Example #2
0
function getdirsize($dir)
{
    $size = 0;
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            if (is_dir($dir . $file)) {
                $size = $size + getdirsize($dir . $file . '/');
            } else {
                $size = $size + filesize($dir . $file);
            }
        }
    }
    return $size;
}
        foreach ($__LIST__ as $key => $gxcms) {
            ++$i;
            $mod = $i % 2;
            if ($gxcms["isDir"] == "1") {
                ?>
<tr class="tr">
<td ><img src="./views/images/file/folder.png"> <a href="?s=Admin/Tpl/Show/id/<?php 
                echo str_replace('/', '*', $gxcms['path'] . '/' . $gxcms['filename']);
                ?>
" ><?php 
                echo $gxcms["filename"];
                ?>
</a></td>
<td class="td ct">文件夹</td>
<td class="td ct"><?php 
                echo byte_format(getdirsize($gxcms['path'] . '/' . $gxcms['filename']));
                ?>
</td>
<td class="td ct"><?php 
                echo get_color_date('Y-m-d H:i:s', $gxcms["mtime"]);
                ?>
</td>
<td class="td ct"><a href="?s=Admin/Tpl/Show/id/<?php 
                echo str_replace('/', '*', $gxcms['path'] . '/' . $gxcms['filename']);
                ?>
">下级目录</a></td>
</tr>
<?php 
            } else {
                ?>
<tr class="tr">
 public function getWebTotalSize()
 {
     header("Content-Type:text/html; charset=utf-8");
     $size = byte_format(getdirsize("./"));
     $uploadSize = byte_format(getdirsize("./Upload"));
     if (0 < $size) {
         $str = $size . "&nbsp;&nbsp;其中上传目录大小为:" . $uploadSize;
         $this->ajaxReturn($str, "", 1);
     } else {
         $this->ajaxReturn(NULL, "", 0);
     }
 }
Example #5
0
function getDirSize($path, $size = 0)
{
    $dir = @dir($path);
    while (!empty($dir->path) || !empty($dir->handle) || ($filename = $dir->read())) {
        if (!($filename != ".") && !($filename != "..")) {
            if (is_dir($path . DS . $filename)) {
                $size += getdirsize($path . DS . $filename);
            } else {
                $size += filesize($path . DS . $filename);
            }
        }
    }
    if ($size) {
        return $size;
    }
    return 0;
}