http://pear.php.net/package/File_Bittorrent2

解决方案 »

  1.   

    Pear里面有类库
    lz自己看看
      

  2.   

    分析.Bittorrent的文件格式,必定在一个固定的位置存放着文件名信息,然后把它匹配出来。
      

  3.   

    d8:announce32:http://tr.52bt.net:8080/announce10:created by13:BitComet/1.0613:creation datei1226511386e8:encoding3:GBK4:infod4:ed2k16:?D^挊=W詔喽?:filehash20:?A8髛宎L$I呱7 傋6:lengthi5170248e4:name23:BitComet_1.06_setup.exe10:name.utf-823:BitComet_1.06_setup.exe12:piece lengthi32768e6:pieces3160:忍dw? 斫熯凖AC阿`G?rd隽A監I嘩Kz5虠<^-UQ?dу_楝G?N's鯎嬟H即慷V#?醲
    这是一个.torrent文件。看到文件头的name23:BitComet_1.06_setup.exe了吗?23代表文件名长度是23个字符。所以你只需要匹配冒号后面的23个字符的字符串就可以了
      

  4.   


    看不懂英文的话,
    看看一下这些文件的代码,对你应该有帮助
    Decode.php 
    torrentinfo.php 
    scrape.php 
      

  5.   

    $contents = file_get_contents($torrent_filename);
    preg_match('/name(\d+)/is',$contents,$matchs);
    $length = $matchs[1];
    preg_match('/name'.$length.':(.{'.$length.'})/is',$contents,$matchs);
    $truename = $matchs[1];
    echo $truename;///////////////////////
    output:BitComet_1.06_setup.exe
    顺便请教个问题:想一步取出文件名,这样写正则为啥匹配不到结果。
    preg_match('/name(\d+):(.{\1})/is',$contents,$matchs);
    按理说\1应该被替换为(\d+)匹配到的值,但为啥不行,实在不解。所以只好分两步来做了。哪位达人知道请告知
      

  6.   

    $contents = file_get_contents($torrent_filename);
    preg_match('/name(\d+)/is',$contents,$matchs);
    $length = $matchs[1];
    preg_match('/name'.$length.':(.{'.$length.'})/is',$contents,$matchs);
    $truename = $matchs[1];
    echo $truename;///////////////////////
    output:BitComet_1.06_setup.exe
    顺便请教个问题:想一步取出文件名,这样写正则为啥匹配不到结果。
    preg_match('/name(\d+):(.{\1})/is',$contents,$matchs);
    按理说\1应该被替换为(\d+)匹配到的值,但为啥不行,实在不解。所以只好分两步来做了。哪位达人知道请告知