This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

How big is the Piratebay?

By: a guest on Feb 9th, 2012  |  syntax: PHP  |  size: 1.19 KB  |  views: 1,004  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. ?>
clone this paste RAW Paste Data