コード例 #1
0
ファイル: func.admin.common.php プロジェクト: laiello/avecms
/**
 * Размер дириктории
 *
 * @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
0
 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
0
ファイル: filestore.php プロジェクト: nirajkaushal/Elgg
/**
 * 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
0
/**
 * 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
0
ファイル: index.php プロジェクト: l1ght13aby/Ubilling
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
0
/**
 * 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
0
ファイル: sols_controller.php プロジェクト: xplico/xplico
 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
0
ファイル: functions.php プロジェクト: feeel1/akina
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
0
ファイル: functions.php プロジェクト: kosmosby/medicine-prof
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
0
ファイル: quota.php プロジェクト: neymanna/fusionforge
    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 
コード例 #11
0
ファイル: home.php プロジェクト: abhinay100/fourimages_app
 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']));
コード例 #12
0
 /**
  * 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
0
ファイル: start.php プロジェクト: laiello/avecms
<?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
0
 /**
  * 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
0
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'));
}
コード例 #16
0
ファイル: about.inc.php プロジェクト: Natolumin/observium
$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 
コード例 #17
0
ファイル: admin_functions.php プロジェクト: 4images/4images
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;
}
コード例 #18
0
ファイル: index.php プロジェクト: feeel1/akina
}
$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);
コード例 #19
0
$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');
コード例 #20
0
ファイル: function.php プロジェクト: 735579768/Ainiku
/**
 *检测目录大小
 */
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;
    //返回大小
}
コード例 #21
0
 public function getSize($prefix, $container_guid)
 {
     if ($container_guid && ($container = get_entity($container_guid)) && ($username = $container->username)) {
         return get_dir_size($this->dir_root . $this->make_file_matrix($username) . $prefix);
     } else {
         return false;
     }
 }