// by:职业菜鸟 2015.8.1
lightbenc.php 文件放到 \Lib\Common 目录下
Lib\Common\common.php 新增下面两个函数
//读BT种子信息
function getBtFileInfo($file)
{
require ‘./Lib/Common/lightbenc.php’;
$Lightbenc = new Lightbenc();
$upload_http_prefix=C(‘upload_http_prefix’);
if(stripos($file,$upload_http_prefix) !== false){
$filepath=str_replace($upload_http_prefix,”,$file);
$filepath="./Uploads/".$filepath;
}else{
$filepath=".".$file;
}
$retval=null;
$fileinfo = $Lightbenc->bdecode_getinfo($filepath);
$fileinfo =$fileinfo[‘info’][‘files’];
foreach($fileinfo as $key=>$value){
$retval[$key][‘name’]=g2u($value[‘path’][0]);
$retval[$key][‘size’]=format_bytes($value[‘length’]);
}
return $retval;
}
//计算机容量单位转换
function format_bytes($size) {
$units = array(‘ B’, ‘ KB’, ‘ MB’, ‘ GB’, ‘ TB’);
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
return round($size, 2).$units[$i];
}
模板调用方法:
<volist name="ppvod[‘son’]" id="ppvodson" key="iii">
<php> $btlist = getBtFileInfo($ppvodson[playpath]); </php>
<volist name="btlist" id="btinfo" key="ii">
{$btinfo[‘name’]}."_".{$btinfo[‘size’]}<br/>
</volist>
</volist>