本文整理汇总了PHP中foldersize函数的典型用法代码示例。如果您正苦于以下问题:PHP foldersize函数的具体用法?PHP foldersize怎么用?PHP foldersize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了foldersize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foldersize
function foldersize($path)
{
$size = 0;
if ($handle = @opendir($path)) {
while (($file = readdir($handle)) !== false) {
if (is_file($path . "/" . $file)) {
$size += filesize($path . "/" . $file);
}
if (is_dir($path . "/" . $file)) {
if ($file != "." && $file != "..") {
$size += foldersize($path . "/" . $file);
}
}
}
}
return $size;
}
示例2: foldersize
function foldersize($path)
{
$total_size = 0;
$files = scandir($path);
$cleanPath = rtrim($path, '/') . '/';
foreach ($files as $t) {
if ($t != "." && $t != "..") {
$currentFile = $cleanPath . $t;
if (is_dir($currentFile)) {
$size = foldersize($currentFile);
$total_size += $size;
} else {
$size = filesize($currentFile);
$total_size += $size;
}
}
}
return $total_size;
}
示例3: uploadFile
function uploadFile($file, $cattype, $cat)
{
global $loguserid, $uploaddirs, $goodfiles, $badfiles, $userquota, $maxSize;
$targetdir = $uploaddirs[$cattype];
$totalsize = foldersize($targetdir);
$filedata = $_FILES[$file];
$c = FetchResult("SELECT COUNT(*) FROM {uploader} WHERE filename={0} AND cattype={1} AND user={2} AND deldate=0", $filedata['name'], $cattype, $loguserid);
if ($c > 0) {
return "You already have a file with this name. Please delete the old copy before uploading a new one.";
}
if ($filedata['size'] == 0) {
if ($filedata['tmp_name'] == '') {
return 'No file given.';
} else {
return 'File is empty.';
}
}
if ($filedata['size'] > $maxSize) {
return 'File is too large. Maximum size allowed is ' . BytesToSize($maxSize) . '.';
}
$randomid = Shake();
$pname = $randomid . '_' . Shake();
$fname = $_FILES['newfile']['name'];
$temp = $_FILES['newfile']['tmp_name'];
$size = $_FILES['size']['size'];
$parts = explode(".", $fname);
$extension = end($parts);
if ($totalsize + $size > $quot) {
Alert(format(__("Uploading \"{0}\" would break the quota."), $fname));
} else {
if (in_array(strtolower($extension), $badfiles) || is_array($goodfiles) && !in_array(strtolower($extension), $goodfiles)) {
return 'Forbidden file type.';
} else {
$description = $_POST['description'];
$big_descr = $cat['showindownloads'] ? $_POST['big_description'] : '';
Query("insert into {uploader} (id, filename, description, big_description, date, user, private, category, deldate, physicalname) values ({7}, {0}, {1}, {6}, {2}, {3}, {4}, {5}, 0, {8})", $fname, $description, time(), $loguserid, $privateFlag, $_POST['cat'], $big_descr, $randomid, $pname);
copy($temp, $targetdir . "/" . $pname);
Report("[b]" . $loguser['name'] . "[/] uploaded file \"[b]" . $fname . "[/]\"" . ($privateFlag ? " (privately)" : ""), $privateFlag);
die(header("Location: " . actionLink("uploaderlist", "", "cat=" . $_POST["cat"])));
}
}
}
示例4: folderSize
function folderSize($dir)
{
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
foreach ($dir_array as $key => $filename) {
if ($filename != ".." && $filename != ".") {
if (is_dir($dir . "/" . $filename)) {
$new_foldersize = foldersize($dir . "/" . $filename);
$count_size = $count_size + $new_foldersize;
} else {
if (is_file($dir . "/" . $filename)) {
$count_size = $count_size + filesize($dir . "/" . $filename);
$count++;
}
}
}
}
return $count_size;
}
示例5: getUsedSpace
/**
* Get used disk space by user_id
*
* @param int $user_id
* @param int $except_size Mb
* @return int used space in Mb or false if throw exception
*/
public function getUsedSpace($user_id, $except_size = 0)
{
$directory = DIR_STORAGE . $user_id . DIR_SEPARATOR;
if (is_dir($directory)) {
$count_size = 0;
$dir_array = scandir($directory);
foreach ($dir_array as $key => $filename) {
if ($filename != '..' && $filename != '.') {
if (is_dir($directory . DIR_SEPARATOR . $filename)) {
$new_foldersize = foldersize($directory . DIR_SEPARATOR . $filename);
$count_size = $count_size + $new_foldersize;
} else {
if (is_file($directory . DIR_SEPARATOR . $filename)) {
$count_size = $count_size + filesize($directory . DIR_SEPARATOR . $filename);
}
}
}
}
return $count_size / 1000000 - $except_size;
} else {
return 0;
}
}
示例6: foldersize
function foldersize($path)
{
$total_size = 0;
$files = scandir($path);
if (!function_exists('scandir')) {
function scandir($path, $sorting_order = 0)
{
$dh = opendir($path);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
if ($sorting_order == 0) {
sort($files);
} else {
rsort($files);
}
return $files;
}
}
foreach ($files as $t) {
if (is_dir($t)) {
// In case of folder
if ($t != "." && $t != "..") {
// Exclude self and parent folder
$size = foldersize($path . "/" . $t);
// print("Dir - $path/$t = $size<br>\n");
$total_size += $size;
}
} else {
// In case of file
$size = filesize($path . "/" . $t);
// print("File - $path/$t = $size<br>\n");
$total_size += $size;
}
}
return $total_size;
}
示例7: foldersize
function foldersize($path)
{
$total_size = 0;
$filesCount = 0;
$foldersCount = 0;
$files = scandir($path);
$cleanPath = rtrim($path, '/') . '/';
foreach ($files as $t) {
if ($t != "." && $t != "..") {
$currentFile = $cleanPath . $t;
if (is_dir($currentFile)) {
$size = foldersize($currentFile);
$total_size += $size[0];
$foldersCount += $size[2] + 1;
$filesCount += $size[1];
} else {
$size2 = filesize($currentFile);
$total_size += $size2;
$filesCount++;
}
}
}
return array($total_size, $filesCount, $foldersCount);
}
示例8: getUsedSpace
/**
* Get used disk space by user_id
*
* @param int $user_id
* @param int $except_size Mb
* @return int used space in Mb or false if throw exception
*/
public function getUsedSpace($user_id, $except_size = 0)
{
$directory = DIR_STORAGE . $user_id . DIR_SEPARATOR;
if (is_dir($directory)) {
$count_size = 0;
$dir_array = scandir($directory);
foreach ($dir_array as $key => $filename) {
// Images and temporary files will be ignored
if ($filename != '..' && $filename != '.' && false === strpos($filename, '_') && false === strpos($filename, '.' . STORAGE_IMAGE_EXTENSION)) {
if (is_dir($directory . DIR_SEPARATOR . $filename)) {
$new_foldersize = foldersize($directory . DIR_SEPARATOR . $filename);
$count_size = $count_size + $new_foldersize;
} else {
if (is_file($directory . DIR_SEPARATOR . $filename)) {
$count_size = $count_size + filesize($directory . DIR_SEPARATOR . $filename);
}
}
}
}
return $count_size / 1000000 - $except_size;
} else {
return 0;
}
}
示例9: foldersize
function foldersize($path)
{
$total_size = 0;
if (!function_exists('scandir')) {
function scandir($path)
{
$dh = opendir($path);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
//print_r($files);
rsort($files);
//print_r($files);
return $files;
}
$files = scandir($path);
foreach ($files as $t) {
if (is_dir($t)) {
// In case of folder
if ($t != "." && $t != "..") {
// Exclude self and parent folder
$size = foldersize($path . "/" . $t);
//print("Dir - $path/$t = $size<br>\n");
$total_size += $size;
}
} else {
// In case of file
$size = @filesize($path . "/" . $t);
//print("File - $path/$t = $size<br>\n");
$total_size += $size;
}
}
$bytes = array('B', 'KB', 'MB', 'GB', 'TB');
foreach ($bytes as $val) {
if ($total_size > 1024) {
$total_size = $total_size / 1024;
} else {
break;
}
}
return @round($total_size, 2) . " " . $val;
} else {
$files = @scandir($path);
foreach ($files as $t) {
if (is_dir($t)) {
// In case of folder
if ($t != "." && $t != "..") {
// Exclude self and parent folder
$size = foldersize($path . "/" . $t);
$total_size += $size;
}
} else {
$size = @filesize($path . "/" . $t);
$total_size += $size;
}
}
$bytes = array('B', 'KB', 'MB', 'GB', 'TB');
foreach ($bytes as $val) {
if ($total_size > 1024) {
$total_size = $total_size / 1024;
} else {
break;
}
}
return @round($total_size, 2) . " " . $val;
}
}
示例10: sizecount
<tr class="band">
<td>清除RSS缓存</td>
<td>cache/rss/</td>
<td class="text-key"><?php
echo sizecount(foldersize(VI_ROOT . 'cache/rss/'));
?>
</td>
<td>删除RSS内容读取缓存,RSS缓存可能在部分功能模块中有涉及和使用</td>
<td><input name="" type="button" class="button" value="立即使用" onclick="location.href='?action=clean&file=rss';" /></td>
</tr>
<tr class="line">
<td>清除模板缓存</td>
<td>static/*/*.htm.php</td>
<td class="text-key"><?php
echo sizecount(foldersize(VI_ROOT . 'cache/compile/'));
?>
</td>
<td>删除各前台页面由 Smarty 产生的缓存,当页面没有正常刷新时使用</td>
<td><input name="" type="button" class="button" value="立即使用" onclick="location.href='?action=clean&file=static';" /></td>
</tr>
</table>
<?php
}
?>
<div class="item">文件对比器</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="table">
示例11: strtoupper
<tr class="line">
<td>VeryIDE 版本</td>
<td class="text-yes"><?php
echo $_G['product']['version'] . ' - ' . strtoupper($_G['product']['charset']) . ' - ' . $_G['product']['build'] . " <span class='text-key'>(" . $_G['version'][$_G['licence']['type']]["name"] . ')</span>';
?>
</td>
<td>安装时间</td>
<td class="text-yes"><?php
echo date("Y-m-d", VI_START);
?>
</td>
</tr>
<tr class="band">
<td>空间占用</td>
<td class="text-yes"><?php
echo sizecount(foldersize(VI_ROOT));
?>
</td>
<td>基准目录</td>
<td class="text-yes"><?php
echo VI_BASE;
?>
</td>
</tr>
<tr class="line">
<td>绝对地址</td>
<td class="text-yes"><?php
echo VI_HOST;
?>
</td>
<td>本地目录</td>
示例12: foldersize
function foldersize($d)
{
$dir = dir($d);
$size = 0;
if ($dir) {
while (false !== ($e = $dir->read())) {
if ($e[0] == '.') {
continue;
}
$c_dir = $d . '/' . $e;
if (is_dir($c_dir)) {
$size = $size + foldersize($c_dir);
} else {
$size = $size + filesize($c_dir);
}
}
$dir->close();
}
return $size;
}
示例13: scandir
}
$files = scandir($current_path . $rfm_subfolder . $subdir);
$n_files = count($files);
//php sorting
$sorted = array();
$current_folder = array();
$prev_folder = array();
foreach ($files as $k => $file) {
if ($file == ".") {
$current_folder = array('file' => $file);
} elseif ($file == "..") {
$prev_folder = array('file' => $file);
} elseif (is_dir($current_path . $rfm_subfolder . $subdir . $file)) {
$date = filemtime($current_path . $rfm_subfolder . $subdir . $file);
if ($show_folder_size) {
$size = foldersize($current_path . $rfm_subfolder . $subdir . $file);
} else {
$size = 0;
}
$file_ext = lang_Type_dir;
$sorted[$k] = array('file' => $file, 'file_lcase' => strtolower($file), 'date' => $date, 'size' => $size, 'extension' => $file_ext, 'extension_lcase' => strtolower($file_ext));
} else {
$file_path = $current_path . $rfm_subfolder . $subdir . $file;
$date = filemtime($file_path);
$size = filesize($file_path);
$file_ext = substr(strrchr($file, '.'), 1);
$sorted[$k] = array('file' => $file, 'file_lcase' => strtolower($file), 'date' => $date, 'size' => $size, 'extension' => $file_ext, 'extension_lcase' => strtolower($file_ext));
}
}
function filenameSort($x, $y)
{
示例14: response
exit;
}
if (trim($_POST['path']) == '') {
response('no path', 400)->send();
exit;
}
$path = $current_path . $_POST['path'];
if (is_dir($path)) {
// can't copy/cut dirs
if ($copy_cut_dirs === false) {
response(sprintf(trans('Copy_Cut_Not_Allowed'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), trans('Folders')), 403)->send();
exit;
}
// size over limit
if ($copy_cut_max_size !== false && is_int($copy_cut_max_size)) {
if ($copy_cut_max_size * 1024 * 1024 < foldersize($path)) {
response(sprintf(trans('Copy_Cut_Size_Limit'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), $copy_cut_max_size), 400)->send();
exit;
}
}
// file count over limit
if ($copy_cut_max_count !== false && is_int($copy_cut_max_count)) {
if ($copy_cut_max_count < filescount($path)) {
response(sprintf(trans('Copy_Cut_Count_Limit'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), $copy_cut_max_count), 400)->send();
exit;
}
}
} else {
// can't copy/cut files
if ($copy_cut_files === false) {
response(sprintf(trans('Copy_Cut_Not_Allowed'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), trans('Files')), 403)->send();
示例15: foldersize
function foldersize($path)
{
$total_size = 0;
$files = scandir($path);
$files = array_slice($files, 2);
foreach ($files as $t) {
if (is_dir($t)) {
//Recurse here
$size = foldersize($path . "/" . $t);
$total_size += $size;
} else {
$size = filesize($path . "/" . $t);
$total_size += $size;
}
}
return $total_size;
}