note 37797 added to function.filesize
| From: | el_goochi at hotmail dot com | Date: | Thu, 27 Nov 2003 15:18:13 +0000 |
| Subject: | note 37797 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61033@lists.php.net to get a copy of this message | ||
I rewrote a script that was posted here before.. the scripts counts all files and folders on your
whole server.. it results a list of all files + a survey of how many files,folders you have + the
size of everything there is on your server.. have fun..
<?php
function direcho($path) {
global $filetotal, $fullsize, $totaldirs;
if ($dir = opendir($path)) {
while (false !== ($file = readdir($dir))) {
if (is_dir($path."/".$file)) { // if it's a dir, check
it's contents too
if ($file != '.' && $file != '..') { // but dont go
recursive on '.' and '..'
echo '<li><b>' . $file . '</b></li><ul>';
direcho($path."/".$file);
echo '</ul>';
$totaldirs++;
}
}
else { //if it's not a dir, just output.
$tab = " ";
$filesize = $tab . '(' . filesize ($path.'/'.$file) . ' kb)';
echo '<li>' . $file . $filesize . '</li>';
$fullsize = $fullsize + filesize ($path.'/'.$file);
$filetotal++;
}
}
closedir($dir);
}
}
direcho('.');
$fullsize = round($fullsize / 1024 / 1024, 2);
echo"<br><br>
<b>Total files</b> - $filetotal files<br>
<b>Total dirs</b> - $totaldirs directories<br>
<b>Total size</b> - $fullsize MB<br>
";
?>
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37797
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37797&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37797&report=yes
Search -- http://master.php.net/manage/user-notes.php