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


PHP dir_size函数代码示例

本文整理汇总了PHP中dir_size函数的典型用法代码示例。如果您正苦于以下问题:PHP dir_size函数的具体用法?PHP dir_size怎么用?PHP dir_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dir_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCache

 /**
  * 获取缓存列表
  * @param int $key 缓存key
  * @return array 用户信息
  */
 public function getCache($key = '')
 {
     $list = array('html' => array('id' => 'html', 'name' => '静态缓存', 'dir' => HTML_PATH, 'size' => sizeFormat(dir_size(HTML_PATH))), 'tpl' => array('id' => 'tpl', 'name' => '模板缓存', 'dir' => CACHE_PATH, 'size' => sizeFormat(dir_size(CACHE_PATH))), 'data' => array('id' => 'data', 'name' => '数据缓存', 'dir' => DATA_PATH, 'size' => sizeFormat(dir_size(DATA_PATH))), 'debug' => array('id' => 'debug', 'name' => '日志缓存', 'dir' => LOG_PATH, 'size' => sizeFormat(dir_size(LOG_PATH))), 'app' => array('id' => 'app', 'name' => '应用缓存', 'dir' => TEMP_PATH, 'size' => sizeFormat(dir_size(TEMP_PATH))), 'run' => array('id' => 'run', 'name' => '运行缓存', 'dir' => RUNTIME_PATH . 'common~runtime.php', 'size' => sizeFormat(filesize(RUNTIME_PATH . 'common~runtime.php'))));
     if ($key) {
         return $list[$key];
     }
     return $list;
 }
开发者ID:kangxinian,项目名称:test,代码行数:13,代码来源:CacheService.class.php

示例2: getFile

 /**
  * 获取缓存列表
  * @param int $key 缓存key
  * @return array 用户信息
  */
 public function getFile($key = '')
 {
     $path = array('Admin' => APP_PATH . 'Admin/', 'Boss' => APP_PATH . 'Boss/', 'Home' => APP_PATH . 'Home/', 'Staff' => APP_PATH . 'Staff/', 'Cache' => CACHE_PATH, 'Log' => LOG_PATH, 'Html' => HTML_PATH, 'App' => TEMP_PATH, 'Data' => DATA_PATH, 'Run' => RUNTIME_PATH . 'common~runtime.php', 'Backup' => './Backup/', 'Images' => './Public/Images/');
     $list = array('Admin' => array('id' => 'Admin', 'name' => 'Admin模块', 'dir' => $path['Admin'], 'size' => sizeFormat(dir_size($path['Admin'])), 'level' => sizeFormat(dir_size($path['Admin']), 'level')), 'Boss' => array('id' => 'Boss', 'name' => 'Boss模块', 'dir' => $path['Boss'], 'size' => sizeFormat(dir_size($path['Boss'])), 'level' => sizeFormat(dir_size($path['Boss']), 'level')), 'Home' => array('id' => 'Home', 'name' => 'Home模块', 'dir' => $path['Home'], 'size' => sizeFormat(dir_size($path['Home'])), 'level' => sizeFormat(dir_size($path['Home']), 'level')), 'Staff' => array('id' => 'Staff', 'name' => 'Staff模块', 'dir' => $path['Staff'], 'size' => sizeFormat(dir_size($path['Staff'])), 'level' => sizeFormat(dir_size($path['Staff']), 'level')), 'Html' => array('id' => 'Html', 'name' => '静态缓存', 'dir' => $path['Html'], 'size' => sizeFormat(dir_size($path['Html'])), 'level' => sizeFormat(dir_size($path['Html']), 'level')), 'Cache' => array('id' => 'Cache', 'name' => '模板缓存', 'dir' => $path['Cache'], 'size' => sizeFormat(dir_size($path['Cache'])), 'level' => sizeFormat(dir_size($path['Cache']), 'level')), 'Data' => array('id' => 'Data', 'name' => '数据缓存', 'dir' => $path['Data'], 'size' => sizeFormat(dir_size($path['Data'])), 'level' => sizeFormat(dir_size($path['Data']), 'level')), 'Log' => array('id' => 'Log', 'name' => '日志缓存', 'dir' => $path['Log'], 'size' => sizeFormat(dir_size($path['Log'])), 'level' => sizeFormat(dir_size($path['Log']), 'level')), 'App' => array('id' => 'App', 'name' => '应用缓存', 'dir' => $path['App'], 'size' => sizeFormat(dir_size($path['App'])), 'level' => sizeFormat(dir_size($path['App']), 'level')), 'Run' => array('id' => 'Run', 'name' => '运行缓存', 'dir' => $path['Run'], 'size' => sizeFormat(filesize($path['Run'])), 'level' => sizeFormat(filesize($path['Run']), 'level')), 'Backup' => array('id' => 'Backup', 'name' => '数据库备份', 'dir' => $path['Backup'], 'size' => sizeFormat(dir_size($path['Backup'])), 'level' => sizeFormat(dir_size($path['Backup']), 'level')), 'Images' => array('id' => 'Images', 'name' => '图片目录', 'dir' => $path['Images'], 'size' => sizeFormat(dir_size($path['Images'])), 'level' => sizeFormat(dir_size($path['Images']), 'level')));
     if ($key) {
         return $list[$key];
     }
     return $list;
 }
开发者ID:NwuNet,项目名称:NetService,代码行数:14,代码来源:FileService.class.php

示例3: __construct

 /**
  * Controller constructor
  *
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->backup_enabled = (bool) ConfigOptions::getValue('backup_enabled');
     $this->how_many_backups = (int) ConfigOptions::getValue('backup_how_many_backups');
     $total_size = dir_size(UPLOAD_PATH);
     $total_size += dir_size(PUBLIC_PATH . '/avatars');
     $total_size += dir_size(PUBLIC_PATH . '/projects_icons');
     $total_size += dir_size(PUBLIC_PATH . '/logos');
     $total_size += backup_module_calculate_database_size(TABLE_PREFIX) * 1.1685;
     $existing_backups = backup_module_get_backups(BACKUP_PATH);
     $this->smarty->assign(array('backup_admin_url' => assemble_url('backup_admin'), 'backup_enabled' => $this->backup_enabled, 'backup_how_many_backups' => $this->how_many_backups, 'total_size' => $total_size, 'backup_dir_size' => dir_size(BACKUP_PATH), 'existing_backups' => $existing_backups));
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:17,代码来源:BackupAdminController.class.php

示例4: dirSize

function dirSize($dir)
{
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
        if ($file != '..' && $file != '.' && !is_dir($dir . '/' . $file)) {
            $mas += filesize($dir . '/' . $file);
        } else {
            if (is_dir($dir . '/' . $file) && $file != '..' && $file != '.') {
                $mas += dir_size($dir . '/' . $file);
            }
        }
    }
    return $mas;
}
开发者ID:anboto,项目名称:xtreamer-web-sdk,代码行数:14,代码来源:sysfunc.php

示例5: calculate_checksum

 /**
  * Calculate backup checksum
  *
  * @param string $backup_name
  * @return float
  */
 function calculate_checksum($backup_name)
 {
     $folders = array(BACKUP_PATH . "/{$backup_name}/upload", BACKUP_PATH . "/{$backup_name}/projects_icons", BACKUP_PATH . "/{$backup_name}/avatars", BACKUP_PATH . "/{$backup_name}/logos");
     $files = array(BACKUP_PATH . "/{$backup_name}/database.sql");
     $total_file_size = 0;
     foreach ($folders as $folder) {
         $total_file_size += dir_size($folder);
     }
     // foreach
     foreach ($files as $file) {
         $total_file_size += filesize($file);
     }
     // foreach
     return md5($total_file_size);
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:21,代码来源:restore.php

示例6: m__space_use

function m__space_use()
{
    $html = '空间占用情况:<span style=\\"color:red;\\">';
    if (!isset($_SESSION['space_size'])) {
        $_SESSION['space_size'] = num_bitunit(dir_size(dirname(__FILE__) . '/../'));
    }
    $html .= $_SESSION['space_size'];
    $html .= '</span>&nbsp;&nbsp;&nbsp;空间文件数量:<span style=\\"color:red;\\">';
    if (!isset($_SESSION['space_files'])) {
        $_SESSION['space_files'] = dir_files(dirname(__FILE__) . '/../');
    }
    $html .= $_SESSION['space_files'];
    $html .= '</span>';
    die('{"code":"0","msg":"' . $html . '"}');
}
开发者ID:cranefly,项目名称:crane,代码行数:15,代码来源:frame.php

示例7: dir_size

function dir_size($dir) { 
    $handle = opendir($dir);
    $size = 0;
    while (false !== ($entry = readdir($handle))) { 
        if($entry != '.' && $entry != '..') { 
            if(is_dir("{$dir}/{$entry}")) { 
                $size += dir_size("{$dir}/{$entry}"); 
            } else { 
                $size += filesize("{$dir}/{$entry}"); 
            }
        }    
    }
    closedir($handle);
    return $size;
}
开发者ID:royalwang,项目名称:saivi,代码行数:15,代码来源:welcome.ctrl.php

示例8: dir_size

function dir_size($dir)
{
    $total_size = 0;
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
        if ($file != '..' && $file != '.' && !is_dir($dir . '/' . $file)) {
            $total_size += filesize($dir . '/' . $file);
        } else {
            if (is_dir($dir . '/' . $file) && $file != '..' && $file != '.') {
                $total_size += dir_size($dir . '/' . $file);
            }
        }
    }
    closedir($handle);
    return $total_size;
}
开发者ID:Kappappa,项目名称:ikupaca,代码行数:16,代码来源:index.php

示例9: dir_size

function dir_size($dir)
{
    $dh = opendir($dir);
    $size = 0;
    while ($file = readdir($dh)) {
        if ($file != '.' and $file != '..') {
            $path = $dir . "/" . $file;
            if (@is_dir($path)) {
                $size += dir_size($path);
            } else {
                $size += filesize($path);
            }
        }
    }
    @closedir($dh);
    return $size;
}
开发者ID:tanny2015,项目名称:DataStructure,代码行数:17,代码来源:admin.func.php

示例10: dir_size

function dir_size($dirname)
{
    $totalsize = 0;
    if ($dirstream = @opendir($dirname)) {
        while (false !== ($filename = readdir($dirstream))) {
            if ($filename != "." && $filename != "..") {
                if (is_file($dirname . "/" . $filename)) {
                    $totalsize += filesize($dirname . "/" . $filename);
                }
                if (is_dir($dirname . "/" . $filename)) {
                    $totalsize += dir_size($dirname . "/" . $filename);
                }
            }
        }
    }
    closedir($dirstream);
    return $totalsize;
}
开发者ID:NikDiamond,项目名称:NikLauncher,代码行数:18,代码来源:launcher.php

示例11: dir_size

/**
 * 获取文件或文件大小
 * @param string $directoty 路径
 * @return int
 */
function dir_size($directoty)
{
    $dir_size = 0;
    if ($dir_handle = @opendir($directoty)) {
        while ($filename = readdir($dir_handle)) {
            $subFile = $directoty . DIRECTORY_SEPARATOR . $filename;
            if ($filename == '.' || $filename == '..') {
                continue;
            } elseif (is_dir($subFile)) {
                $dir_size += dir_size($subFile);
            } elseif (is_file($subFile)) {
                $dir_size += filesize($subFile);
            }
        }
        closedir($dir_handle);
    }
    return $dir_size;
}
开发者ID:NwuNet,项目名称:NetService,代码行数:23,代码来源:function.php

示例12: dir_size

function dir_size($path)
{
    static $dir_size;
    $list_dir = list_dir($path);
    if (is_array($list_dir)) {
        foreach ($list_dir as $row) {
            if ($row['type'] == 'dir') {
                dir_size($row['path']);
            } else {
                $dir_size += filesize($row['path']);
            }
        }
    }
    return $dir_size;
}
开发者ID:AlvarodelRosal,项目名称:xppass,代码行数:15,代码来源:utils.php

示例13: clear_dir_if_size

function clear_dir_if_size($dir, $max_size)
{
    $size = is_dir($dir) ? dir_size($dir) : 0;
    if ($size > $max_size) {
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($files as $file) {
            $op = $file->isDir() ? 'rmdir' : 'unlink';
            $op($file->getRealPath());
        }
    }
    return $size > $max_size;
}
开发者ID:rlugojr,项目名称:tilecraft,代码行数:12,代码来源:endpoint.php

示例14: dir_size

function dir_size($dir)
{
    $sz = 0;
    if ($str = @opendir($dir)) {
        while (($fnm = readdir($str)) !== false) {
            if ($fnm[0] != '.') {
                if (is_file($dir . '/' . $fnm)) {
                    $sz += filesize($dir . '/' . $fnm);
                } else {
                    if (is_dir($dir . '/' . $fnm)) {
                        $sz += dir_size($dir . '/' . $fnm);
                    }
                }
            }
        }
    }
    closedir($str);
    return $sz;
}
开发者ID:tipsun91,项目名称:punbb-mod,代码行数:19,代码来源:uploads.php

示例15: userfiles_build_menu

function userfiles_build_menu()
{
    $quota = 10000;
    // in kilobytes
    if ($_SERVER['USER'] == 'listen') {
        $quota = 10000000;
    }
    if ($_SERVER['USER'] == 'jwdavidson') {
        $quota = 10000000;
    }
    $content .= "<html>\n\t<head>\n\t<script type='text/javascript' src='{$_SERVER['WEB_ROOT']}/resources/javascript/setplan.js' />\n\t<link rel='stylesheet' href='{$_SERVER['WEB_ROOT']}/stylesheet'>\n\t</head>\n\t<body>";
    $fileowner = $_SERVER['USER'];
    $fileowner_files_dir = "{$_SERVER['USER_ROOT']}/files";
    if (is_dir($fileowner_files_dir)) {
        $groupmembers = files_list("{$fileowner_files_dir}", "*", "date");
    } else {
        $groupmembers = array();
    }
    if (count($groupmembers) > 0) {
        foreach ($groupmembers as $fileownerfile) {
            $fileownerfile = basename($fileownerfile);
            if (strpos($fileownerfile, '.jpg') || strpos($fileownerfile, '.png') || strpos($fileownerfile, '.gif')) {
                $photolist[] = $fileownerfile;
            } elseif (strpos($fileownerfile, '.wav') || strpos($fileownerfile, '.mp3') || strpos($fileownerfile, '.m4a') || strpos($fileownerfile, '.au') || strpos($fileownerfile, '.wma') || strpos($fileownerfile, '.ogg')) {
                $audiolist[] = $fileownerfile;
            } else {
                $misclist[] = $fileownerfile;
            }
        }
    }
    unset($groupmembers);
    if (isset($photolist)) {
        foreach ($photolist as $photo) {
            $photosize = getimagesize("{$_SERVER['USER_ROOT']}/files/{$photo}");
            $photo_link = "<img src=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$photo}\\' alt=\\'{$photo}\\' title=\\'{$photo}\\' width=\\'{$photosize['0']}\\' height=\\'{$photosize['1']}\\' />";
            $photo_content .= "\n\t\t\t<li><a  href=\"javascript:insertTag('textbox','{$photo_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/posticon.gif' />\n\t\t\t{$photo}\n\t\t\t</a>\n\t\t\t<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$photo}/menu'>\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n";
        }
        $content .= "<li class='listheader'>Images</li>\n{$photo_content}\n\n";
    }
    if (isset($audiolist)) {
        foreach ($audiolist as $audio) {
            $audio_link = "<a href=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$audio}\\' alt=\\'{$audio}\\'/>";
            $audio_content .= "\n\t\t\t<li><a  href=\"javascript:insertTag('textbox','{$audio_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/smallaudio.gif' />\n\t\t\t{$audio}\n\t\t\t</a>\n\t\t\t<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$audio}/menu'>\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n";
        }
        $content .= "<li class='listheader'>Sounds</li>\n{$audio_content}\n\n";
    }
    if (isset($misclist)) {
        foreach ($misclist as $misc) {
            $misc_display = files_decode_safe_name($misc);
            $misc_link = "<a href=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$misc}\\'>{$misc_display}</a>";
            $misc_content .= "\n\t\t\t<li><a  href=\"javascript:insertTag('textbox','{$misc_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='{$_SERVER['WEB_ROOT']}/resources/graphics/posticon.gif' />\n\t\t\t{$misc}\n\t\t\t</a>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$misc}/menu'>\n\t\t\t<img src='{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n";
        }
        $content .= "<li class='listheader'>Documents</li>\n{$misc_content}\n\n";
    }
    if (($ds = dir_size("{$_SERVER['USER_ROOT']}/files/")) < 1024 * $quota) {
        $uploadform = "<li>" . round($ds / 1024) . " K used of {$quota} K total\n\t\t<form target='hiddenUploadFrame' action='{$_SERVER['WEB_ROOT']}/scripts/userfiles.php' method='post' enctype='multipart/form-data'>\n\t\t<input type='file' name='files[1]' id='fileToUpload'/>\n\t\t<input type='submit' value='upload file' onclick=\"element('insert').style.display='none';void(0);\"/>\n\t\t<input type='hidden' name='action' value='write files'/>\n\t\t<input type='hidden' name='fileowner' value='{$_SERVER['USER']}'/>\n\t\t<input type='hidden' name='source' value='menu'/>\n\t\t<iframe id='hiddenUploadFrame' name='hiddenUploadFrame' style='height: 1px; width: 1px; visibility: hidden;'></iframe>\n\t\t</form></li>\n";
    } else {
        $content .= "<li><strong>QUOTA EXCEEDED. Please delete " . files_format_size($ds - $quota * 1024) . " of files.</li>";
    }
    $content .= "<li><a href='{$_SERVER['WEB_ROOT']}/userfiles/manage/{$_SERVER['USER']}' target='_top'><img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['toolsicon']}'> manage your files</a></li>\n";
    $content .= "<li><a href='javascript:window.location.reload();'><img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['toolsicon']}'> refresh the list</a></li>\n";
    $content = $uploadform . $content;
    return $content;
}
开发者ID:joshuawdavidson,项目名称:planwatch,代码行数:64,代码来源:userfiles.php


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