Advertisement
Guest User

How big is the Piratebay?

a guest
Feb 9th, 2012
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. ini_set("memory_limit", "2048M");
  3.  
  4. $file = file_get_contents("complete");
  5. $file_array = explode("\n", "$file");
  6. $size_of_array = sizeof($file_array);
  7. $size_of_tpb = "0";
  8.  
  9. for ($i = 0; $i < $size_of_array; $i++) {
  10.     $line_array = explode("|", $file_array["$i"]);
  11.     if (isset($line_array["2"]))
  12.         $size_of_tpb += $line_array["2"];
  13. }
  14. echo "The pirate bay is: " . bytes2English($size_of_tpb);
  15.  
  16.  
  17. // Source: http://robert-lerner.com/convert-bytes-to-mb-gb-tb-and-pb-with-php.php
  18. // Convert the number of bytes to size of tpb.
  19. function bytes2English($filesize)
  20. {
  21.     if ($filesize < 1048676)
  22.         return number_format($filesize / 1024, 1) . " KB";
  23.     if ($filesize >= 1048576 && $filesize < 1073741824)
  24.         return number_format($filesize / 1048576, 1) . " MB";
  25.     if ($filesize >= 1073741824 && $filesize < 1099511627776)
  26.         return number_format($filesize / 1073741824, 2) . " GB";
  27.     if ($filesize >= 1099511627776)
  28.         return number_format($filesize / 1099511627776, 2) . " TB";
  29.     if ($filesize >= 1125899906842624)
  30.         //Currently, PB won't show due to PHP limitations
  31.  
  32.         return number_format($filesize / 1125899906842624, 3) . " PB";
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement