本文整理汇总了PHP中get_dir_size函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dir_size函数的具体用法?PHP get_dir_size怎么用?PHP get_dir_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dir_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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']));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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">
(
<?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: <b>" . format_file_size($global_info['database_size']['4images']) . "</b>";
} else {
$db_status = format_file_size(!empty($global_info['database_size']['total']));
示例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;
}
}
示例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'));
示例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;
}
}
示例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'));
}