File.php 907 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace UCore\Helper;
  3. class File
  4. {
  5. /**
  6. * 文件大小
  7. *
  8. * @param $filesize
  9. * @return string
  10. */
  11. public static function sizecount($filesize)
  12. {
  13. if ($filesize == null || $filesize == '' || $filesize == 0) return '0';
  14. if ($filesize >= 1073741824) {
  15. $filesize = round($filesize / 1073741824 * 100) / 100 . ' gb';
  16. } elseif ($filesize >= 1048576) {
  17. $filesize = round($filesize / 1048576 * 100) / 100 . ' mb';
  18. } elseif ($filesize >= 1024) {
  19. $filesize = round($filesize / 1024 * 100) / 100 . ' kb';
  20. } else {
  21. $filesize = $filesize . ' bytes';
  22. }
  23. return $filesize;
  24. }
  25. /**
  26. * 连接组装
  27. * @param $_infohash
  28. * @return string
  29. */
  30. static public function magnet($_infohash)
  31. {
  32. return 'magnet:?xt=urn:btih:' . $_infohash;
  33. }
  34. }