本文整理汇总了PHP中getDirSize函数的典型用法代码示例。如果您正苦于以下问题:PHP getDirSize函数的具体用法?PHP getDirSize怎么用?PHP getDirSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDirSize函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDirSize
function getDirSize($dir)
{
$size = 0;
foreach (new RecursiveDirectoryIterator($dir) as $child) {
if ($child->isDir()) {
$size += getDirSize($child);
} else {
$size += filesize($child->getPathname());
}
}
return $size;
}
示例2: check_autothumbs_bytes
function check_autothumbs_bytes($dirs)
{
$max_size = getBytesFromString(mainConfiguration::getInstance()->get("system", "quota-files-and-images"));
if ($max_size != 0) {
$busy_size = 0;
foreach ($dirs as $dir) {
$busy_size += getDirSize($dir);
}
if ($busy_size >= $max_size) {
header('Status: 404 Not Found', true, 404);
header('HTTP/1.0 404 Not Found', true, 404);
exit;
}
}
}
示例3: getDirSize
function getDirSize($t_dir)
{
$filesize = 0;
$dirh = opendir($t_dir);
while (false !== ($filename = readdir($dirh))) {
if ($filename != '.' && $filename != '..') {
if (is_file($t_dir . $filename)) {
$filesize += filesize($t_dir . $filename);
} else {
getDirSize($t_dir . $filename . '/');
//재귀호출
}
}
}
closedir($dirh);
return $filesize;
}
示例4: _get_dir_size
function _get_dir_size($dir)
{
$handle = opendir($dir);
$sizeResult = 0;
while (false !== ($FolderOrFile = readdir($handle))) {
if ($FolderOrFile != "." && $FolderOrFile != "..") {
if (is_dir("{$dir}/{$FolderOrFile}")) {
$sizeResult += getDirSize("{$dir}/{$FolderOrFile}");
} else {
$sizeResult += filesize("{$dir}/{$FolderOrFile}");
}
}
}
closedir($handle);
return $sizeResult;
}
示例5: db_restoreOp
/**
* 数据库恢复
*/
public function db_restoreOp()
{
$lang = Language::getLangContent();
/**
* 删除
*/
if ($_POST['form_submit'] == 'ok') {
if (!empty($_POST['dir_name']) && is_array($_POST['dir_name'])) {
$dir = BASE_ROOT_PATH . DS . 'sql_back';
foreach ($_POST['dir_name'] as $k => $v) {
if (file_exists(BASE_ROOT_PATH . DS . 'sql_back' . DS . $v)) {
$file_list = array();
readFileList($dir . DS . $v, $file_list);
/**
* 删除文件
*/
if (is_array($file_list)) {
foreach ($file_list as $k_file => $v_file) {
@unlink($dir . DS . $v . DS . $v_file);
}
}
/**
* 删除目录
*/
@rmdir($dir . DS . $v);
} else {
showMessage($lang['db_restore_file_not_exists']);
}
}
showMessage($lang['db_restore_del_succ']);
} else {
showMessage($lang['db_restore_choose_file_to_del']);
}
}
$tmp_list = readDirList(BASE_ROOT_PATH . DS . 'sql_back');
/**
* 整理内容
*/
$dir_list = array();
if (is_array($tmp_list)) {
foreach ($tmp_list as $k => $v) {
$dir_list[$k]['name'] = $v;
$dir_list[$k]['make_time'] = date('Y-m-d H:i:s', filemtime(BASE_ROOT_PATH . DS . 'sql_back' . DS . $v));
$dir_list[$k]['size'] = number_format(getDirSize(BASE_ROOT_PATH . DS . 'sql_back' . DS . $v) / 1024, 2) . 'KB';
$dir_list[$k]['file_num'] = count(glob(BASE_ROOT_PATH . DS . 'sql_back' . DS . $v . DS . "*.sql"));
}
}
Tpl::output('dir_list', $dir_list);
Tpl::showpage('db.restore');
}
示例6: getDirSize
/**
* 获取目录大小
*
* @param string $path 目录
* @param int $size 目录大小
* @return int 整型类型的返回结果
*/
function getDirSize($path, $size = 0)
{
$dir = @dir($path);
if (!empty($dir->path) && !empty($dir->handle)) {
while ($filename = $dir->read()) {
if ($filename != '.' && $filename != '..') {
if (is_dir($path . DS . $filename)) {
$size += getDirSize($path . DS . $filename);
} else {
$size += filesize($path . DS . $filename);
}
}
}
}
return $size ? $size : 0;
}
示例7: urlEncode
if ($link == "") {
// we're already in $baseDir, so skip the file
if ($path == "") {
continue;
}
$f["link"] = $_SERVER["PHP_SELF"];
} else {
$link .= "/";
$f["link"] = $_SERVER["PHP_SELF"] . "?path=" . urlEncode($link);
}
$f["isBack"] = true;
if ($useBackForDirUp) {
$f["displayName"] = translate("[ back ]");
}
} else {
$filesInDir = getDirSize($entry);
if ($filesInDir == 1) {
$f["niceSize"] = translate("1 item");
} else {
$f["niceSize"] = sprintf(translate("%d items"), $filesInDir);
}
$f["link"] = getPathLink($path . $entry);
}
} else {
if (is_link($entry)) {
$linkTarget = readlink($entry);
$pi = pathinfo($linkTarget);
$scriptDir = dirname($_SERVER["SCRIPT_FILENAME"]);
if (strpos($pi["dirname"], $scriptDir) === 0) {
$f["type"] = "<LINK>";
// links have no date, so take the target's date
示例8: filter_var
*/
include "../settings.php";
//Gets our path to the log file
//Allow users to specify a number of days in the url ?days=
//If missing or invalid set days = 1
if (isset($_GET['days'])) {
$days = filter_var($_GET['days'], FILTER_SANITIZE_NUMBER_INT);
if (!filter_var($days, FILTER_VALIDATE_INT)) {
$days = 1;
}
} else {
$days = 1;
}
echo "<h2>Days: " . $days . "</h2>";
$upload_dir = "../upload";
echo 'Upload Directory Size: ' . round(getDirSize($upload_dir) / 1024, 2) . "KB" . "<br/>";
//echo $log_file . "<br/>";
//we have a number of different messages logged.
$severities = array("success", "error", "fail");
$types = array("upload", "fetch", "pasted");
echo "Log Size: " . round(filesize("log.txt") / 1024, 2) . "KB" . "<br/>";
foreach ($severities as $severity) {
echo "<h3>" . $severity . "</h3>";
foreach ($types as $type) {
echo " " . $type . " - " . count_logs($severity, $type, $days, $log_file) . "<br/>";
}
}
/*
* Summarises info in the log files by counting occurances of terms
* name: count_logs
* @param string $filter1 The first term to filter logs by, this should be a severity tag
示例9: getDirSize
<img src="keyboardIcons/d.svg" id="icon-5"/>
<span>Right</span>
</div>
<div class="icon-group">
<img src="keyboardIcons/q.svg" id="icon-6"/>
<span>Toggle Pointer</span>
</div>
<div class="icon-group">
<img src="keyboardIcons/mouse_icon.svg" id="icon-7"/>
<span>Move camera after pointer is invisible</span>
</div>
</div>
<?php
require "functions.php";
$dirSize = getDirSize("assets");
$imageDirSize = getDirSize("assets/textures");
echo "<span id='data-span'>Loading digital assets, models, textures, ect...</span>";
echo "<progress id='loadingBar' value=0 max=" . $dirSize . "></progress>";
//<span id='loadPercent'>60%</span>
?>
<?php
function retrieveTextures($dir)
{
$files = array();
foreach (new RecursiveDirectoryIterator($dir) as $child) {
if ($child->isDir()) {
$files = array_merge($files, retrieveTextures($child));
} else {
$files[] = $child->getPathname();
}
}
示例10: getBusyDiskSize
function getBusyDiskSize($v33030abc929f083da5f6c3f755b46034 = array('/images', '/files'))
{
clearstatcache();
$v1105d5ffdd5622b43f4a0b16afb0e886 = 0;
foreach ($v33030abc929f083da5f6c3f755b46034 as $v736007832d2167baaae763fd3a3f3cf1) {
$v1105d5ffdd5622b43f4a0b16afb0e886 += getDirSize(CURRENT_WORKING_DIR . $v736007832d2167baaae763fd3a3f3cf1);
}
return $v1105d5ffdd5622b43f4a0b16afb0e886;
}
示例11: getDirSize
function getDirSize($path)
{
$total_size = 0;
//指定したのがファイルだった場合はサイズを返して終了。
if (is_file($path)) {
return filesize($path);
} elseif (is_dir($path)) {
$basename = basename($path);
//カレントディレクトリと上位ディレクトリを指している場合はここで終了。
if ($basename == '.' || $basename == '..') {
return 0;
}
//ディレクトリ内のファイル一覧を入手。
$file_list = scandir($path);
foreach ($file_list as $file) {
//ディレクトリ内の各ファイルを引数にして、自分自身を呼び出す。
$total_size += getDirSize($path . '/' . $file);
}
return $total_size;
} else {
return 0;
}
}
示例12: getDirSize
function getDirSize($f)
{
if (is_dir($f)) {
$fs = scandir($f);
unset($fs[0]);
unset($fs[1]);
$cnt = 0;
foreach ($fs as $a) {
$cnt += getDirSize($f . "/" . $a);
}
return $cnt;
} else {
return filesize($f);
}
}
示例13: fileExceedQuota
function fileExceedQuota($file_path, $quota, $used, $manual_file_size = false)
{
if ($quota == 0) {
return false;
}
$quota = $quota * 1024 * 1024;
if ($manual_file_size === false) {
$filesize = getDirSize($file_path);
} else {
$filesize = $manual_file_size;
}
return $used + $filesize > $quota;
}