基本信息
源码名称:附件是BT种子时显示详细资源信息插件
源码大小:5.52KB
文件格式:.rar
开发语言:PHP
更新时间:2015-01-04
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
<?php
require "./include/common.inc.php";
@$query = $db->query("SELECT attachment, filename FROM {$tablepre}attachments WHERE aid='$aid'");
if ($query) {
$btfile=$db->fetch_array($query);
$btfileext = $btfile['filename'];
$btfilename = $btfile['attachment'];
}
else {
echo 'database_error';
dexit();
}
if (strlen($btfilename) == 0) {
echo 'no_attach';
dexit();
}
$fjcd=strlen($btfilename)-8;
if (strtolower(fileext($btfileext))!= "torrent") {
echo 'not_torrent';
dexit();
}
$btfilename="./attachments/".$btfilename;
include("include/BDecode.php");
include("include/BEncode.php");
function announceoutput($array)
{
if (!isset($array["peers"][0]))
{
echo "Not a tracker announce block. Falling back on classic.<BR><BR>";
classicoutput($array, "(Not checked)");
exit;
}
echo "<H2>Client configuration options</H2>";
echo "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2> ";
foreach ($array as $left => $right)
{
if ($left == "peers")
continue;
if (is_array($right))
$myright = "<I>Error</I>";
else
$myright = $right;
echo "<TR><TD ALIGN=RIGHT>".$left."</TD><TD>".$myright."</TD></TR>\n";
}
echo "</TABLE><BR><H2>Peers</H2><PRE>";
foreach ($array["peers"] as $data)
{
if (!is_array($data)) // special case: [0] == true means empty list
{
echo "(Empty results)\n";
break;
}
echo bin2hex($data["peer id"])." at ".$data["ip"].":".$data["port"]."\n";
}
echo "</PRE>";
}
function classicoutput($array, $infohash)
{
if (isset($array["info"]["pieces"]))
$array["info"]["pieces"] = "<i>Checksum data (" . strlen ($array["info"]["pieces"]) / 20 . " pieces)</i>";
//echo "Info hash: <TT>$infohash</TT><BR>";
echo "<PRE>";
//print_r(cleaner($array));
echo "</PRE>";
}
function escapeURL($url)
{
$ret = "";
$i=0;
while (strlen($url) > $i)
{
$ret .= "%".$url[$i].$url[$i 1];
$i =2;
}
return $ret;
}
function cleaner($array)
{
if (!is_array($array))
return $array;
$newarray = array();
foreach($array as $left => $right)
{
if (is_string($left))
$newleft = stringcleaner(stripslashes($left));
else
$newleft = $left;
if (is_string($right))
$newright = stringcleaner($right);
else if (is_array($right))
$newright = cleaner($right);
else
$newright = $right;
$newarray[$newleft] = $newright;
}
return $newarray;
}
function stringcleaner($str)
{
$len = strlen($str);
for ($i=0; $i < $len; $i )
{
if (ord($str[$i]) < 32 || ord($str[$i]) > 128)
return "<B>".bin2hex($str)."</B>";
}
return $str;
}
function sizecount($filesize) {
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;
}
$fd = @fopen($btfilename, "rb");
if (!$fd) {
showmessage("该附件可能已被删除");
}
$alltorrent = fread($fd, filesize($btfilename));
fclose($fd);
$array = BDecode($alltorrent);
$infohash = "<I>Not applicable</I>";
if (isset($array["info"]))
if (is_array($array["info"])) {
if (function_exists("sha1"))
$infohash = sha1(BEncode($array["info"]));
else
$infohash = "(PHP 4.3.0 or greater is required for hashing)</TT><BR>";
}
if (isset($array["creation date"])) {
if (is_numeric($array["creation date"]))
$data=date("Y 年 m 月 d 日", $array["creation date"]);
else
$data=$array["creation date"];
}
$info = $array["info"]; // I'll need it
if (isset($info["files"])) {
foreach ($info["files"] as $file) {
if (isset($file["path"][1])) {
$files.=$file["path"][0];
for ($i=1; isset($file["path"][$i]); $i )
$files.="/".$file["path"][$i];
}
else {
$files.=$file["path"][0];
}
$files.= " <font color='blue'>(".sizecount($file["length"]).")</font><BR>";
$allsize=$allsize $file["length"];
}
}
else {
$files=$info["name"]." <font color='blue'>(".sizecount($info["length"]).")</font>";
$info["name"]="";
$allsize=$info["length"];
}
$allsize=sizecount($allsize);
include template('track');
?>