| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace UCore\Helper;
- class File
- {
- /**
- * 文件大小
- *
- * @param $filesize
- * @return string
- */
- public static function sizecount($filesize)
- {
- if ($filesize == null || $filesize == '' || $filesize == 0) return '0';
- if ($filesize >= 1073741824) {
- $filesize = round($filesize / 1073741824 * 100) / 100 . ' gb';
- } elseif ($filesize >= 1048576) {
- $filesize = round($filesize / 1048576 * 100) / 100 . ' mb';
- } elseif ($filesize >= 1024) {
- $filesize = round($filesize / 1024 * 100) / 100 . ' kb';
- } else {
- $filesize = $filesize . ' bytes';
- }
- return $filesize;
- }
- /**
- * 连接组装
- * @param $_infohash
- * @return string
- */
- static public function magnet($_infohash)
- {
- return 'magnet:?xt=urn:btih:' . $_infohash;
- }
- }
|