From a49c63af0964234ff6c059033d644b788bdeb669 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Fri, 17 Jan 2020 10:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E5=88=B0Bencode?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Class/Bencode.php | 141 ------------------------------------------ 1 file changed, 141 deletions(-) delete mode 100644 app/Class/Bencode.php diff --git a/app/Class/Bencode.php b/app/Class/Bencode.php deleted file mode 100644 index 641597f..0000000 --- a/app/Class/Bencode.php +++ /dev/null @@ -1,141 +0,0 @@ - $value) { - if ($key !== ++$check) { - $list = false; - break; - } - } - if ($list) { - $return .= 'l'; - foreach ($data as $value) { - $return .= self::encode($value); - } - } else { - $return .= 'd'; - foreach ($data as $key => $value) { - $return .= self::encode(strval($key)); - $return .= self::encode($value); - } - } - $return .= 'e'; - } elseif (is_integer($data)) { - $return = 'i' . $data . 'e'; - } else { - $return = strlen($data) . ':' . $data; - } - return $return; - } - /** - * Given a path to a file, decode the contents of it - * - * @param string $path - * @return mixed - */ - public static function load($path) - { - if (is_file($path)) { - return self::decode(file_get_contents($path)); - } - return null; - } - /** - * Given a path for a file, encode the contents of it - * - * @param string $path - * @param $data - * @return mixed - */ - public static function dump($path, $data) - { - return file_put_contents($path, self::encode($data)); - } -}