|
|
|
get folder size - พี่ๆ มี code ตรวจสอบขนาดของ โฟรเดอ แบบตามพาทเปล่าครับ เช่น c:\windows |
|
|
|
|
|
|
|
<?php
function foldersize( $path )
{
$size = 0;
if( $dir = @opendir( $path )) {
while(($file = readdir($dir)) !== false ) {
if( is_dir( "$path/$file" ) && $file != '.' && $file != '..' ) {
$size += foldersize( "$path/$file" );
}
if( is_file( "$path/$file" )) {
$size += filesize( "$path/$file" );
}
}
closedir($dir);
}
return $size;
}
$sizes['files'] = 0;
if( $dir = @opendir( '.' )) {
while(($file = readdir($dir)) !== false ) {
if( is_dir( "$file" ) && $file != '.' && $file != '..' ) {
$sizes[$file] = foldersize( "$file" );
}
if( is_file( "$file" )) {
$sizes['files'] += filesize( "$file" );
}
}
closedir($dir);
}
$totsize = 0;
foreach( $sizes as $fsize ) {
$totsize += $fsize;
}
echo "<table>";
foreach( $sizes as $key => $size ) {
$perc = 100 * $size / $totsize;
$width = 4 * $perc;
$percstr = number_format( $perc, 1 ) . '%';
$sizestr = number_format( $size );
printf( '<tr><td>%s</td><td align="right">%s</td><td><img src="red_dot.gif" width="%s" ' .
'height="10" border="0" alt="%s"> %s</td>', $key, $sizestr, $width, $percstr,$percstr );
}
echo "</table>";
?>
deawx
[email protected]
|
|
|
|
|
Date :
2009-03-14 18:17:06 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับพี่ deawx
|
|
|
|
|
Date :
2009-03-14 21:15:34 |
By :
voravut2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณหลายๆเลยคับ ^^
|
|
|
|
|
Date :
2012-05-03 10:49:11 |
By :
Maenae191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|