コード例 #1
0
 public static function bdecode_getinfo($filename)
 {
     $t = Lightbenc::bdecode(file_get_contents($filename, FILE_BINARY));
     $t['info_hash'] = sha1(Lightbenc::bencode($t['info']));
     if (isset($t['info']['files']) && is_array($t['info']['files'])) {
         //multifile
         $t['info']['size'] = 0;
         $t['info']['filecount'] = 0;
         foreach ($t['info']['files'] as $file) {
             $t['info']['filecount']++;
             $t['info']['size'] += $file['length'];
         }
     } else {
         $t['info']['size'] = $t['info']['length'];
         $t['info']["filecount"] = 1;
         $t['info']['files'][0]['path'] = $t['info']['name'];
         $t['info']['files'][0]['length'] = $t['info']['length'];
     }
     return $t;
 }