• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_dir_size函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_dir_size

/**
 * Размер дириктории
 *
 * @param string $directory наименование директории
 * @return int
 */
function get_dir_size($directory)
{
    if (!is_dir($directory)) {
        return -1;
    }
    $size = 0;
    if ($DIR = opendir($directory)) {
        while (($dirfile = readdir($DIR)) !== false) {
            if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..') {
                continue;
            }
            if (@is_file($directory . '/' . $dirfile)) {
                $size += filesize($directory . '/' . $dirfile);
            } elseif (@is_dir($directory . '/' . $dirfile)) {
                $dirSize = get_dir_size($directory . '/' . $dirfile);
                if ($dirSize >= 0) {
                    $size += $dirSize;
                } else {
                    return -1;
                }
            }
        }
        closedir($DIR);
    }
    return $size;
}
开发者ID:laiello,项目名称:avecms,代码行数:32,代码来源:func.admin.common.php


示例2: setrunsize

 public function setrunsize()
 {
     set_time_limit(0);
     $data['size'] = get_dir_size(SITE_PATH . '/Data/cache/') / 1000 . 'k';
     $data['time'] = time();
     F('runtimecachesize', $data);
     die("{$data['size']}" . " Time:" . time_format($data['time']));
 }
开发者ID:735579768,项目名称:Ainiku,代码行数:8,代码来源:PathInfoPlugin.class.php


示例3: get_dir_size

/**
 * Get the size of the specified directory.
 *
 * @param string $dir        The full path of the directory
 * @param int    $total_size Add to current dir size
 *
 * @return int The size of the directory in bytes
 */
function get_dir_size($dir, $total_size = 0)
{
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        if (in_array($file, array('.', '..'))) {
            continue;
        }
        if (is_dir($dir . $file)) {
            $total_size = get_dir_size($dir . $file . "/", $total_size);
        } else {
            $total_size += filesize($dir . $file);
        }
    }
    @closedir($handle);
    return $total_size;
}
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:24,代码来源:filestore.php


示例4: get_dir_size

/**
 * Get the size of the specified directory.
 *
 * @param string $dir       The full path of the directory
 * @param int    $totalsize Add to current dir size
 *
 * @return int The size of the directory.
 */
function get_dir_size($dir, $totalsize = 0)
{
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        if (eregi("^\\.{1,2}\$", $file)) {
            continue;
        }
        if (is_dir($dir . $file)) {
            $totalsize = get_dir_size($dir . $file . "/", $totalsize);
        } else {
            $totalsize += filesize($dir . $file);
        }
    }
    @closedir($handle);
    return $totalsize;
}
开发者ID:rcolomoc,项目名称:Master-Red-Social,代码行数:24,代码来源:filestore.php


示例5: get_dir_size

function get_dir_size($dir)
{
    $size = 0;
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (is_dir($dir . $file)) {
                if ($file != '.' and $file != '..') {
                    $size += get_dir_size($dir . $file . '/');
                }
            } else {
                $size += filesize($dir . $file);
            }
        }
        closedir($dh);
    }
    return $size;
}
开发者ID:l1ght13aby,项目名称:Ubilling,代码行数:17,代码来源:index.php


示例6: syntax_cache_maintenance

/**
 * Trashes all files in syntax cache that are too old.
 */
function syntax_cache_maintenance($incoming_file_size)
{
    global $phpbb_root_path, $board_config;
    // We only want to do cache maintenance every now and then, because
    // for large caches this will be a costly operation
    if (do_syntax_cache_maintenance() && $board_config['syntax_cache_files_expire'] != 0) {
        $dh = @opendir($phpbb_root_path . 'cache/syntax') or message_die(GENERAL_ERROR, 'Syntax Highlighting cache maintenance could not be performed: make sure cache/syntax directory exists');
        $file = readdir($dh);
        while ($file !== false) {
            // file names of cache files are an md5 (32 characters) + ".dat" (4 characters)
            if (strlen($file) == 36) {
                //
                // The function filectime gets the time a file was last *changed*, not
                // the time that it was created. However, because we're only ever reading
                // from cache files we can get away with this :)
                //
                $creation_time = filectime($phpbb_root_path . 'cache/syntax/' . $file);
                if ($creation_time + $board_config['syntax_cache_files_expire'] < time()) {
                    // Cache file too old - smash it
                    unlink($phpbb_root_path . 'cache/syntax/' . $file);
                }
            }
            $file = readdir($dh);
        }
    }
    $space_left = $board_config['syntax_cache_dir_size'] - get_dir_size($phpbb_root_path . 'cache/syntax/');
    //echo "space left: $space_left  ifs $incoming_file_size";
    if ($space_left < $incoming_file_size && $board_config['syntax_cache_dir_size'] != 0) {
        // Not enough space! Trash some files...
        // It's hard to pick a strategy for deleting files - lets just delete files
        // until there's enough space
        $dh = @opendir($phpbb_root_path . 'cache/syntax/') or message_die(GENERAL_ERROR, 'Syntax Highlighting cache maintenance could not be performed: make sure cache/syntax directory exists');
        $file = readdir($dh);
        while ($file !== false) {
            //echo $file . '<br />';
            if (is_dir($phpbb_root_path . 'cache/syntax/' . $file) || $file == 'index.htm' || $file == 'cache.txt') {
                $file = readdir($dh);
                continue;
            }
            unlink($phpbb_root_path . 'cache/syntax/' . $file);
            //echo "unlinked $file<br />";
            $file = readdir($dh);
        }
        closedir($dh);
    }
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:49,代码来源:functions_syntax_cache.php


示例7: get_dir_size

 private function get_dir_size($dir_name)
 {
     $dir_size = 0;
     if (is_dir($dir_name)) {
         if ($dh = opendir($dir_name)) {
             while (($file = readdir($dh)) !== false) {
                 if ($file != '.' && $file != '..') {
                     if (is_file($dir_name . '/' . $file)) {
                         $dir_size += filesize($dir_name . '/' . $file);
                     }
                     /* check for any new directory inside this directory */
                     if (is_dir($dir_name . '/' . $file)) {
                         $dir_size += get_dir_size($dir_name . '/' . $file);
                     }
                 }
             }
         }
     }
     closedir($dh);
     return $dir_size;
 }
开发者ID:xplico,项目名称:xplico,代码行数:21,代码来源:sols_controller.php


示例8: get_dir_size

function get_dir_size($dir_name)
{
    $dir_size = 0;
    $file_count = 0;
    $file24_count = 0;
    if (is_dir($dir_name)) {
        if ($dh = opendir($dir_name)) {
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' and $file != '..') {
                    if (is_file($dir_name . '/' . $file)) {
                        $dir_size += filesize($dir_name . '/' . $file);
                        //24*60*60
                        if (time() - filemtime($dir_name . '/' . $file) < 86400) {
                            $file24_count++;
                        }
                        $file_count++;
                    }
                    if (is_dir($dir_name . '/' . $file)) {
                        list($foo_dir_size, $foo_file_count, $foo_file24_count) = get_dir_size($dir_name . '/' . $file);
                        $dir_size += $foo_dir_size;
                        $file_count += $foo_file_count;
                        $file24_count += $foo_file24_count;
                    }
                }
            }
            closedir($dh);
        }
    }
    return array($dir_size, $file_count, $file24_count);
}
开发者ID:feeel1,项目名称:akina,代码行数:30,代码来源:functions.php


示例9: get_dir_size

function get_dir_size($dir)
{
    if (is_file($dir)) {
        return array('size' => filesize($dir), 'howmany' => 0);
    }
    if ($dh = opendir($dir)) {
        $size = 0;
        $n = 0;
        while (($file = readdir($dh)) !== false) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $n++;
            $data = get_dir_size($dir . '/' . $file);
            $size += $data['size'];
            $n += $data['howmany'];
        }
        closedir($dh);
        return array('size' => $size, 'howmany' => $n);
    }
    return array('size' => 0, 'howmany' => 0);
}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:22,代码来源:functions.php


示例10: while

    while ($e = db_fetch_array($res_db)) {
        print_debug("users name={$e['user_name']} status={$e['unix_status']}");
        if ($e["unix_status"] != "N") {
            $users["{$e['user_id']}"]["user_id"] = $e["user_id"];
            $users["{$e['user_id']}"]["user_name"] = "{$e['user_name']}";
            $users["{$e['user_id']}"]["realname"] = "{$e['realname']}";
            $users["{$e['user_id']}"]["unix_status"] = "{$e['unix_status']}";
            $users["{$e['user_id']}"]["disk_size"] = 0;
        }
    }
}
foreach ($users as $u) {
    print_debug("---------------------------------------");
    $user_id = $u["user_id"];
    $dir = $ftp_dir . $u["user_name"];
    $size = get_dir_size($dir);
    $users["{$user_id}"]["disk_size"] += convert_bytes_to_mega($size);
    print_debug("{$user_id} user={$u['user_name']} dir={$dir} size={$size}");
}
?>
<table width="800px" cellpadding="2" cellspacing="0" border="0">
	<tr style="">
		<td style="border-top:thick solid #808080;font-weight:bold" colspan="3">
			<?php 
echo _('Projects ressources use');
?>
		</td>
		<td style="border-top:thick solid #808080" colspan="7">
			<span style="font-size:10px">
				(&nbsp;
				<?php 
开发者ID:neymanna,项目名称:fusionforge,代码行数:31,代码来源:quota.php


示例11: show_table_header

 show_table_header($lang['nav_general_main'], 4);
 //1
 echo "<tr class=\"" . get_row_bg() . "\">\n";
 echo "<td width=\"16%\"><b>" . $lang['categories'] . "</b></td><td width=\"16%\">" . $total_categories . "</td>\n";
 $size = 0;
 echo "<td width=\"16%\"><b>" . $lang['media_directory'] . "</b></td><td width=\"16%\">" . format_file_size(get_dir_size(MEDIA_PATH)) . "</td>\n";
 echo "</tr>";
 //2
 echo "<tr class=\"" . get_row_bg() . "\">\n";
 $sql = "SELECT COUNT(*) as temp_images\n          FROM " . IMAGES_TEMP_TABLE;
 $row = $site_db->query_firstrow($sql);
 $awaiting_validation = preg_replace("/" . $site_template->start . "num_images" . $site_template->end . "/siU", $row['temp_images'], $lang['images_awaiting_validation']);
 $awaiting_validation = sprintf("<a href=\"" . $site_sess->url("validateimages.php?action=validateimages") . "\">%s</a>", $awaiting_validation);
 echo "<td width=\"16%\"><b>" . $lang['images'] . "</b></td><td width=\"16%\">" . $total_images . " / " . $awaiting_validation . "</td>\n";
 $size = 0;
 echo "<td width=\"16%\"><b>" . $lang['thumb_directory'] . "</b></td><td width=\"16%\">" . format_file_size(get_dir_size(THUMB_PATH)) . "</td>\n";
 echo "</tr>";
 //3
 echo "<tr class=\"" . get_row_bg() . "\">\n";
 $sql = "SELECT COUNT(*) as users\n          FROM " . USERS_TABLE . "\n          WHERE " . get_user_table_field("", "user_id") . " <> " . GUEST;
 $row = $site_db->query_firstrow($sql);
 echo "<td width=\"16%\"><b>" . $lang['users'] . "</b></td><td width=\"16%\">" . $row['users'] . "</td>\n";
 echo "<td width=\"16%\"><b>" . $lang['database'] . "</b></td><td width=\"16%\">";
 include ROOT_PATH . 'includes/db_utils.php';
 get_database_size();
 if (!empty($global_info['database_size']['total'])) {
     if (!empty($global_info['database_size']['4images'])) {
         $db_status = $lang['homestats_total'] . " <b>" . format_file_size($global_info['database_size']['total']) . "</b> / ";
         $db_status .= "4images:&nbsp;<b>" . format_file_size($global_info['database_size']['4images']) . "</b>";
     } else {
         $db_status = format_file_size(!empty($global_info['database_size']['total']));
开发者ID:abhinay100,项目名称:fourimages_app,代码行数:31,代码来源:home.php


示例12: getSize

 /**
  * Returns the size of all data stored under a directory in the disk store.
  *
  * @param string $prefix         The prefix to check under.
  * @param string $container_guid The guid of the entity whose data you want to check.
  *
  * @return int|false
  */
 public function getSize($prefix, $container_guid)
 {
     if ($container_guid) {
         $dir = new \Elgg\EntityDirLocator($container_guid);
         return get_dir_size($this->dir_root . $dir . $prefix);
     } else {
         return false;
     }
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:17,代码来源:ElggDiskFilestore.php


示例13: header

<?php

/**
 * AVE.cms
 *
 * @package AVE.cms
 * @subpackage admin
 * @filesource
 */
if (!defined('ACP')) {
    header('Location:index.php');
    exit;
}
get_ave_info();
get_editable_module();
//$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/main.txt', 'index');
$AVE_Template->assign('php_version', @PHP_VERSION != '' ? @PHP_VERSION : 'unknow');
$AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version());
$AVE_Template->assign('cache_size', format_size(get_dir_size($AVE_Template->compile_dir) + get_dir_size($AVE_Template->cache_dir_root)));
$AVE_Template->assign('mysql_size', get_mysql_size());
$AVE_Template->assign('navi', $AVE_Template->fetch('navi/navi.tpl'));
$AVE_Template->assign('content', $AVE_Template->fetch('start.tpl'));
开发者ID:laiello,项目名称:avecms,代码行数:22,代码来源:start.php


示例14: getSize

 /**
  * Returns the size of all data stored under a directory in the disk store.
  *
  * @param string $prefix         Optional/ The prefix to check under.
  * @param string $container_guid The guid of the entity whose data you want to check.
  *
  * @return int|false
  */
 public function getSize($prefix = '', $container_guid)
 {
     if ($container_guid) {
         return get_dir_size($this->dir_root . $this->makeFileMatrix($container_guid) . $prefix);
     } else {
         return false;
     }
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:16,代码来源:ElggDiskFilestore.php


示例15: cacheShow

function cacheShow()
{
    global $AVE_Template;
    $showCache = format_size(get_dir_size($AVE_Template->compile_dir) + get_dir_size($AVE_Template->cache_dir_root));
    echo json_encode(array($showCache, 'accept'));
}
开发者ID:RGBvision,项目名称:AVE.cms,代码行数:6,代码来源:func.admin.common.php


示例16: dbFetchCell

$stat_printersupplies = dbFetchCell('SELECT COUNT(*) FROM `printersupplies`');
$stat_hrdev = dbFetchCell('SELECT COUNT(*) FROM `hrDevice`');
$stat_entphys = dbFetchCell('SELECT COUNT(*) FROM `entPhysical`');
$stat_ipv4_addy = dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses`');
$stat_ipv4_nets = dbFetchCell('SELECT COUNT(*) FROM `ipv4_networks`');
$stat_ipv6_addy = dbFetchCell('SELECT COUNT(*) FROM `ipv6_addresses`');
$stat_ipv6_nets = dbFetchCell('SELECT COUNT(*) FROM `ipv6_networks`');
$stat_pw = dbFetchCell('SELECT COUNT(*) FROM `pseudowires`');
$stat_vrf = dbFetchCell('SELECT COUNT(*) FROM `vrfs`');
$stat_vlans = dbFetchCell('SELECT COUNT(*) FROM `vlans`');
$stat_ns_vsvrs = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers`');
$stat_ns_svcs = dbFetchCell('SELECT COUNT(*) FROM `netscaler_services`');
$stat_vms = dbFetchCell('SELECT COUNT(*) FROM `vminfo`');
$stat_ip_sla = dbFetchCell('SELECT COUNT(*) FROM `slas`');
$stat_db = get_db_size();
$stat_rrd = get_dir_size($config['rrd_dir']);
?>
      <table class="table table-striped table-condensed">
        <tbody>
          <tr>
            <td style="width: 45%;"><i class="oicon-database"></i> <strong>DB size</strong></td><td><span class="pull-right"><?php 
echo formatStorage($stat_db);
?>
</span></td>
            <td style="width: 45%;"><i class="oicon-box-zipper"></i> <strong>RRD size</strong></td><td><span class="pull-right"><?php 
echo formatStorage($stat_rrd);
?>
</span></td>
          </tr>
          <tr>
            <td><i class="oicon-servers"></i> <strong>Devices</strong></td><td><span class="pull-right"><?php 
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:about.inc.php


示例17: get_dir_size

function get_dir_size($dir)
{
    $size = 0;
    $dir = !preg_match("#/\$#", $dir) ? $dir . "/" : $dir;
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        if (preg_match("/^\\.{1,2}\$/", $file)) {
            continue;
        }
        $size += is_dir($dir . $file) ? get_dir_size($dir . $file . "/") : filesize($dir . $file);
    }
    @closedir($handle);
    return $size;
}
开发者ID:4images,项目名称:4images,代码行数:14,代码来源:admin_functions.php


示例18: elseif

}
$parse_main['{width_preview_elements}'] = '';
$parse_main['{height_preview_elements}'] = '';
if (isset($config['width_preview_elements']) and $config['width_preview_elements'] != '') {
    $parse_main['{width_preview_elements}'] = 'value="' . $config['width_preview_elements'] . '" ';
} elseif (isset($config['height_preview_elements']) and $config['height_preview_elements'] != '') {
    $parse_main['{height_preview_elements}'] = 'value="' . $config['height_preview_elements'] . '" ';
}
if (isset($error) and is_array($error)) {
    $parse_main['{error}'] = parse_template(get_template('info'), array("{type}" => 'error', "{title}" => "Ошибка!", "{text}" => implode("<br />", $error)));
} else {
    $parse_main['{error}'] = '';
}
$cachefile = $config['cachefile'];
if (!file_exists($cachefile) or time() - @filemtime($cachefile) > $config['cache_time']) {
    touch($cachefile);
    //чтобы только один пользователь запускал подсчет
    list($size, $images_total, $images_h24) = get_dir_size($config['uploaddir']);
    $size = formatfilesize($size);
    file_put_contents($cachefile, "{$images_total}|{$size}|{$images_h24}");
} elseif (file_exists($cachefile)) {
    list($images_total, $size, $images_h24) = explode("|", file_get_contents($cachefile));
}
$parse_main['{size}'] = $size;
$parse_main['{images}'] = $images_total;
$parse_main['{images24}'] = $images_h24;
$parse_main['{site_http_path}'] = $config['site_url'];
if (!$parse_main['{content}']) {
    $parse_main['{content}'] = '';
}
echo parse_template(get_template('index'), $parse_main);
开发者ID:feeel1,项目名称:akina,代码行数:31,代码来源:index.php


示例19: _

$quotas_disk[] = $q;
$q["name"] = _('Ftp project directory');
$q["path"] = "{$ftp_dir}";
$q["size"] = get_dir_size("{$ftp_dir}");
$q["quota_label"] = _('With ftp and home quota control');
$quota_tot_1 += $q["size"];
$quotas_disk[] = $q;
$q["name"] = _('CVS project directory');
$q["path"] = "{$cvs_dir}";
$q["size"] = get_dir_size("{$cvs_dir}");
$q["quota_label"] = _('With cvs and svn quota control');
$quota_tot_scm += $q["size"];
$quotas_disk[] = $q;
$q["name"] = _('Subversion project directory');
$q["path"] = "{$svn_dir}";
$q["size"] = get_dir_size("{$svn_dir}");
$q["quota_label"] = _('With cvs and svn quota control');
$quota_tot_scm += $q["size"];
$quotas_disk[] = $q;
//echo "chroot = $chroot_dir <br />";
//echo "ftp = $ftp_dir <br />";
// echo "group = $group_dir <br />";
// echo "svn = $svn_dir <br />";
// echo "cvs = $cvs_dir <br />";
// print_debug(print_r($quotas, true));
?>

<table width="500px" cellpadding="2" cellspacing="0" border="0">
	<tr style="font-weight:bold">
		<td colspan="3" style="border-top:thick solid #808080" align="center"><?php 
echo _('Database');
开发者ID:neymanna,项目名称:fusionforge,代码行数:31,代码来源:quota_project.php


示例20: get_dir_size

/**
 *检测目录大小
 */
function get_dir_size($dir)
{
    $sizeResult = 0;
    $handle = opendir($dir);
    //打开文件流
    while (false !== ($FolderOrFile = readdir($handle))) {
        if ($FolderOrFile != "." && $FolderOrFile != "..") {
            if (is_dir("{$dir}/{$FolderOrFile}")) {
                $sizeResult += get_dir_size("{$dir}/{$FolderOrFile}");
                //递归调用
            } else {
                $sizeResult += filesize("{$dir}/{$FolderOrFile}");
            }
        }
    }
    closedir($handle);
    //关闭文件流
    return $sizeResult;
    //返回大小
}
开发者ID:735579768,项目名称:Ainiku,代码行数:23,代码来源:function.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_directory_list函数代码示例发布时间:2022-05-15
下一篇:
PHP get_dir_file_info函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap