Subdomain Posts
PHP | 3 days ago
PHP | 160 days ago
PHP | 162 days ago
PHP | 197 days ago
PHP | 209 days ago
PHP | 250 days ago
PHP | 432 days ago
PHP | 478 days ago
PHP | 568 days ago
PHP | 568 days ago
Recent Posts
None | 10 sec ago
None | 12 sec ago
None | 19 sec ago
None | 21 sec ago
None | 24 sec ago
None | 26 sec ago
C++ | 34 sec ago
None | 1 min ago
C | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Sam Yong on the 30th of Aug 2008 01:44:53 PM Download | Raw | Embed | Report
  1. /************************************
  2.  
  3.  Recursive directory size calculation function
  4.  http://thephpcode.blogspot.com/
  5.  
  6.  Author: Sam Yong
  7.  blog: http://thephpdeveloper.blogspot.com/
  8.  
  9.  No illegal use of this script is allowed.
  10.  
  11. ************************************/
  12.  
  13. function dirsize($dirname) {
  14. if (!is_dir($dirname) || !is_readable($dirname)) {
  15. // check whether the directory is valid.
  16. return false;
  17. }
  18.  
  19. $dirname_stack[] = $dirname;
  20. $size = 0;
  21.  
  22. do {
  23. $dirname = array_shift($dirname_stack);
  24. $handle = opendir($dirname);
  25. while (false !== ($file = readdir($handle))) {
  26. if ($file != '.' && $file != '..' && is_readable($dirname . DIRECTORY_SEPARATOR . $file)) {
  27. if (is_dir($dirname . DIRECTORY_SEPARATOR . $file)) {
  28. $dirname_stack[] = $dirname . DIRECTORY_SEPARATOR . $file;
  29. }
  30. $size += filesize($dirname . DIRECTORY_SEPARATOR . $file);
  31. }
  32. }
  33. closedir($handle);
  34. } while (count($dirname_stack) > 0);
  35.  
  36. return $size;
  37. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: